Let $M$ be a positive number to be chosen later. For $z\in\mathbb{R}^n$, define
$$f_1(z) = \frac12 \langle Az,z-x\rangle + M\langle z-x, x-y\rangle$$ and
$$f_2(z) = \frac12 \langle Bz,z-y\rangle + M\langle z-y, y-x\rangle$$
Note that $\nabla^2 f_1\equiv A$ and $\nabla^2 f_2\equiv B$; also, $f_1(x)=0$ and $f_2(y)=0$. Choose $M$ large enough so that $f_1(y)<0$ and $f_2(x)<0$; this is possible because the term multiplied by $M$ is negative in both cases.
Let $f=\max(f_1,f_2)$. This is a convex function whose Hessian is $A$ where $f_1>f_2$, and is $B$ where $f_1<f_2$. The inequalities $f_1>f_2$ and $f_1<f_2$ determine disjoint open sets $U,V$ that contain $x$ and $y$, respectively.
If a smooth function is desired, convolve $f$ with a compactly supported smooth bump $\phi$. When the diameter of $\operatorname{supp}\phi$ is smaller than $$\min(\operatorname{dist}(x, \partial U), \operatorname{dist}(y, \partial V))$$ the Hessian at $x$ will remain $A$ because in a neighborhood of $x$, $$\nabla^2 (f*\phi) = \nabla^2 (f_1*\phi) = (\nabla^2 f_1)*\phi=A$$
Same for $y$.