That's basic linear algebra.
We use only X,Z cohordinates so we are working in the Euclidean plane $\mathbb R^2$.
Put the origin in the point where the axis of your 2d object is placed. And works in such cohordinates. In practice if $(X_0,Z_0)$ are the cohordinates of the 2d object you use coordinates $(X-X_0,Z-Z_0)$ instead of $(X,Z)$.
Now some Thery:
In $\mathbb R^2$ linear transformations that fixes the origin (and a rotation is one of them) are determined by $2\times 2$ matrices.
Consider points $e_1=(1,0)$ and $e_2=(0,1)$. Then the matrix $\begin{pmatrix} a & b\\ c & d\end{pmatrix}$ sends $e_1$ to point $(a,c)$ and $e_2$ to point $(b,d)$.
And in general $\begin{pmatrix} a & b\\ c & d\end{pmatrix}\begin{pmatrix} x \\ y \end{pmatrix}=\begin{pmatrix} ax + by\\ cx+ dy\end{pmatrix}$, where $\begin{pmatrix} x \\ y \end{pmatrix}$ is another way to say $(x,y)$.
(see here for more details on matrix multiplication)
The nice fact is that the images of $e_1$ and $e_2$ determines the matrix.
Now your case.
Start with your object facing the point $(1,0)$, so the camera is on a point $(X,0)$ with $X>0$. If the camera move to point $(X,Z)$ you want to rotate the object so taht it faces the camera, which is the same that facing the normalized pont $(\frac{X}{\sqrt{X^2+Z^2}}, \frac{Z}{\sqrt{X^2+Z^2}})$ that we denote by $(\bar X,\bar Z)$.
So you want a matrix $M$ so that $M e_1=(\bar X,\bar Z)$ and that maps $e_2$ to the normal to $(\bar X,\bar Z)=(-\bar Z,\bar X)$. This matrix is simply
$$M=\begin{pmatrix}\bar X & -\bar Z\\ \bar Z&\bar X\end{pmatrix}$$
The matrix $M$, which you see it depends on $X,Z$ will rotate your object as desired.