This is an obstruction theory problem; you regard $v\in H^2(M;\mathbb{Z}/2)$ as a homotopy class of maps $v: M\to K(\mathbb{Z}/2,2)$, then ask if $v$ lifts through the universal Stiefel-Whitney class $w_2:BSO\to K(\mathbb{Z}/2,2)$. The first obstruction is $\beta(v^2)\in H^5(M;\mathbb{Z})$, as mentioned by Theo Johnson-Freyd in the comments, coming from the fact that $w_2^2(E)$ is the mod $2$ reduction of $p_1(E)$ for any real vector bundle $E$. The secondary obstruction is more subtle (it will have indeterminacy given by a choice of integral lift of $v^2$, for example) but I would be surprised if there is no information on it in the literature.

I think the state of the art on this question might still be Teichner's paper

*Teichner, Peter*, **6-dimensional manifolds without totally algebraic homology**, Proc. Am. Math. Soc. 123, No. 9, 2909-2914 (1995). ZBL0858.57033.

Teichner shows that if $\operatorname{dim}(M)\le 5$, then $\beta(v^2)$ is the only obstruction to $v$ being $w_2(E)$ for some real vector bundle $E$. On the other hand, he constructs examples of manifolds in all dimensions $n\ge 6$ with classes $v\in H^2(M;\mathbb{Z}/2)$ such that $\beta(v^2)\neq 0$. He also shows that any $v\in H^2(M;\mathbb{Z}/2)$ which is Poincaré dual to a codimension $2$ submanifold $N\subseteq M$ is $w_2(E)$ for some $E$.

An older paper which also seems relevant is

*Suzuki, H.*, **On the realization of the Stiefel-Whitney characteristic classes by submanifolds**, Tohoku Math. J., II. Ser. 10, 91-115 (1958). ZBL0107.17001.