Measuring misalignment between two positions on sky
Assuming you mean the angle between the meridian line through A and the great circle that goes through points A and B, then it goes something like this.

Define vectors from the origin to A and B assuming they lie on a unit sphere, such that $x_A= \cos \delta_A \cos \phi_A$, $ y_A = \cos \delta_A \sin \phi_A$ and $z_A= \sin \delta_A$, and similar for B. Here $\phi$ refers to right Ascension and $\delta$ is declination.

The great circles in question define planes that pass through the origin. A normal to the plane defined by OAB is given by the vector product $\vec{n_1}=\vec{A}\times \vec{B}$. Similarly a great circle passing through the O, A and the NCP $(0, 0, 1)$ has a normal of $\vec{n_2}= \vec{A}\times (0,0,1) = (y_A, -x_A, 0)$.

The angle you are looking for is the angle between these two normal vectors, which can be found from scalar product in the usual way.
$$\cos \theta = \frac{\vec{n_1}\cdot \vec{n_2}}{|n_1||n_2|}=\frac{\cos \phi_{A}(y_{A}z_{B} - y_{B}z_A) + \sin \phi_{A}(x_Az_B - x_Bz_A)}{|\vec{A}\times \vec{B}|}$$