I want to prove the following statement: Let $X$ be a scheme over a field $k$ locally of finite presentation, and let $S$ be a closed subset of $X$ of codimension $\geq 2$. If $\mathcal{E}$ is a locally free sheaf of rank $n$ on $X-S$, then one can extend $\mathcal{E}$ to $X$ uniquely.
I think the following argument should be able to show the statement: $\mathcal{E}$ is described by a cocycle $(g_{ij})$ where $g=g_{ij}$ is an element of $\mathrm{GL_n}(\Gamma(U,\mathcal{O}_{X-S}))$. Here $U$ is an open of $X-S$ that is a restriction of an affine open $\mathrm{Spec}(B)$ of $X$, i.e., $\mathrm{Spec}(B)|_{X-S}=U$. At this point, if I assume $X$ is also normal, then I can use Algebraic Hartog to deduce $\mathrm{Spec}(B)=\Gamma(U,\mathcal{O}_{X-S})$. Therefore, the same cocycle $(g_{ij})$ defines the unique extension to $X$.
However, in this argument, I still need to assume $X$ is normal. How can I remove this condition?
I also want to ask a more general question. For a group scheme $G$ over $X$ (with some further mild assumptions on $X$ if necessary), when can we still extend a $G$-torsor on $X-S$ to $X$ uniquely?
As Mohan points out in the comments, your actual question is doomed to have a positive answer. To help conceptualize this, it's useful to set up some terminology.
Let us fix $X$ to be a locally Noetherian integral scheme. For a $\mathcal{O}_X$-module $\mathcal{F}$ on $X$, we define $\mathcal{F}^\ast$ to be the sheaf-theoretic dual: $\mathcal{Hom}(\mathcal{F},\mathcal{O}_X)$.
Denote by $\mathbf{Rflx}(X)$ the category of reflexive coherent sheaves on $X$, and $\mathbf{Vect}(X)$ the full subcategory of vector bundles on $X$.
Let us further call an open subset $U\subseteq X$ large if $Z:=X-U$ has the property that $\mathrm{depth}(\mathcal{O}_{X,z})$ is at least $2$ for all points $z$ in $Z$. If $X$ is normal (or Cohen--Macaulay) then this is equivalent to the fact that $Z$ is of codimension at least $2$ in $X$.
The slogan for this is simple: reflexive sheaves don't change under the passage to reflexive subsets.
It also suggests a simple reality.
Proof: Indeed, if $\mathcal{V}$ is a vector bundle on $X$ extending $U$, then
$$j^\ast\mathcal{V}\cong \mathcal{E}\cong j^\ast j_\ast\mathcal{E}.$$
As $j_\ast\mathcal{E}$ and $\mathcal{V}$ are reflexive sheaves on $X$, we see by the proposition that $\mathcal{V}\cong j_\ast\mathcal{E}$, and so the claim follows. $\blacksquare$
With this in mind, we can inspect the example mentioned by Mohan.
Example: Let
$$M=\left(k[x,y,z]e_1\oplus k[x,y,z]e_2\oplus k[x,y,z]e_3\right)/(xe_1+ye_2+ze_3),$$
and set $\mathcal{F}=\widetilde{M}$. We claim that $\mathcal{F}$ is a reflexive module which is not a vector bundle, but $\mathcal{F}|_U$ is a vector bundle, where $U=\mathbb{A}^3_k-\{(0,0,0)\}$. This will show by the above corollary that $\mathcal{F}|_U$ is a vector bundle on $U$ which does not extend to $\mathbb{A}^3_k$.
Let us first show that $\mathcal{F}$ is not a vector bundle, but $\mathcal{F}|_U$ is. It suffices to assume that $k$ is algebraically closed. Then, recall that as $\mathbb{A}^3_k$ and $U$ are reduced Noetherian schemes, and $\mathcal{F}$ is coherent, that it suffices to show that the function
$$r\colon \mathbb{A}^3_k(k)\to\mathbb{Z},\qquad x\mapsto \dim_{k(x)}(\mathcal{F}\otimes k(x)),$$
is not constant, but is constant on $U(k)$. Indeed, this follows from Tag 0FWG, together with the fact that $r$ is upper semi-continuous (see Mohan's answer here), and that the $\mathbb{A}^3(k)$ is very dense in $\mathbb{A}^3_k$ (see [GW, Proposition 3.3.5]), and similarly for $U$. But, this is clear as if $x=(a,b,c)\in k^3$ then $\mathcal{F}\otimes k(x)$ is $$(ke_1\oplus ke_2\oplus ke_3)/(ae_1+be_2+ce_3),$$
which evidently has dimension $2$ unless $(a,b,c)=(0,0,0)$.
Finally, to show that $\mathcal{F}$ is reflexive, we see by Tag 0AY5 and the fact that $\mathcal{F}|_U$ is a vector bundle (and so reflexive), it suffices to show that the stalk $\mathcal{F}_{(x,y,z)}$ has depth at least $2$. But, one can explicitly check that $(x,y)$ is a regular sequence for this module. $\blacksquare$
A similar story exists for $G$-torsors, where $G$ is a smooth group $X$-scheme, at least when $X$ is normal (but this is most likely just an assumption of convenience). The operative notion being that of a reflexive pseudo-torsor for $G$. This is developed in the joint paper [IKY] of mine, specifically in §A.6. Of course, when $G=\mathrm{GL}_{n,X}$ this recovers the theory of reflexive modules discussed above.
The only extra noteworthy result that doesn't have an analogue in the theory of reflexive modules is the following.
In practice one applies this for a faithful representation $\rho\colon \mathcal{G}\hookrightarrow \mathrm{GL}(\Lambda_0)_X$. If one thinks of $\mathcal{Q}$ as an association of reflexive $\mathcal{O}_X$-modules to representations $\Lambda$ of $\mathcal{G}$ (e.g., see [IKY, Proposition A.24 and Proposition A.25]) then this says that it suffices to check that the reflexive $\mathcal{O}_X$-module $\mathcal{Q}(\Lambda_0)$ is a vector bundle.
The reason I mention this is two-fold:
it's surprisingly useful (it plays a non-trivial role in the proof of the main results of [IKY]),
its proof looks more similar to that which you attempted to carry out in your post (cf. [IKY, Remark A.27]).
EDIT: Let me just add the observation made by ASadMathematician above, which is that your question does admit a positive answer if $X$ is regular and dimension at most $2$. This follows easily from our above discussion (namely Proposition 1) and the following (classical) fact.
References
[GW] Görtz, U. and Wedhorn, T., 2010. Algebraic Geometry I: Schemes. Vieweg+ Teubner.
[IKY] https://arxiv.org/pdf/2310.08472.pdf