For an example, let $X = \mathbb{P}^2$ and $Y$ a smooth curve in $X$ of genus $>0$ (over an algebraically closed field). Since $X$ is smooth, any line bundle on an open set $U$ extends to a line bundle on $X$ so the map $Pic(X) \operatorname{Pic}(X) \to Pic(U)$ \operatorname{Pic}(U)$is surjective. However, Since$Pic(X) \operatorname{Pic}(X) \cong \mathbb{Z}$whereas mathbb{Z}$, it follows that the image of $Pic(Y)$ \operatorname{Pic}(U)$in$\operatorname{Pic}(Y)$is of rank$1$and is independent of$U \supset Y$. Since$\operatorname{Pic}(Y)$is not even finitely generated , so the map we see that there exist (many) line bundles on$Pic(U) \to Pic(Y)$is Y$ which do not surjectiveextend to any open $U \supset Y$.
For an example, let $X = \mathbb{P}^2$ and $Y$ a smooth curve in $X$ of genus $>0$ (over an algebraically closed field). Since $X$ is smooth, any line bundle on an open set $U$ extends to a line bundle on $X$ so the map $Pic(X) \to Pic(U)$ is surjective. However, $Pic(X) \cong \mathbb{Z}$ whereas $Pic(Y)$ is not even finitely generated, so the map $Pic(U) \to Pic(Y)$ is not surjective.