For simplicity, suppose $X$ is a smooth projective variety of dimension $n \geq 3$, and $Y$ is a smooth subvariety of $X$. If the dimension of $Y$ is $n-1$, i.e. $Y$ is a divisor, then we can construct a line bundle $L_Y$ associated to the divisor $[Y]$, and furthermore we can construct a section of $L_Y$, whose zero set is just $Y$. This can be found in textbooks on algebraic geometry, e.g. Hartshorne.
But suppose the dimension of $Y$ is $n-2$, are there ways to construct a rank-2 bundle associated to $Y$, and a section of this rank 2 bundle whose zero set is just $Y$? Furthermore, when the dimension of $Y$ is $n-k$? References are welcomed!
For codimension 2 there is so called Serre's construction (it can be found, for instance, in the book of Okonek-Schneider-Spindler); a necessary condition for it is that $\det N_{Y/X}$ is isomorphic to the restriction to $Y$ of a line bundle on $X$.