It is from the process of deriving the identity itself.
First, let us use the double-angle formula $\cos2\theta = 2\cos^{2}\theta - 1$. Solving for $\cos^{2}\theta$, we get $$\cos^{2}\theta = \frac{1 + \cos 2\theta}{2}.$$
Replacing $\theta$ by $\frac{\theta}{2}$, we get \begin{align*}\cos^{2}\left(\frac{\theta}{2}\right) &= \frac{1 + \cos\theta}{2} \\ \cos\left(\frac{\theta}{2}\right) &= \pm\sqrt{\frac{1 + \cos\theta}{2}}\end{align*}
Using the identity $\sin^{2}\theta + \cos^{2}\theta = 1$ to get $\sin \frac{\theta}{2}$,
\begin{align*}\sin^{2}\left(\frac{\theta}{2}\right) + \cos^{2}\left(\frac{\theta}{2}\right) &= 1 \\ \sin^{2}\left(\frac{\theta}{2}\right) + \frac{1 + \cos\theta}{2} &= 1 \\ \sin^{2}\left(\frac{\theta}{2}\right) &= 1 - \frac{1 + \cos\theta}{2} \\ \sin^{2}\left(\frac{\theta}{2}\right) &= \frac{2 - 1 - \cos\theta}{2} \\ \sin^{2}\left(\frac{\theta}{2}\right) &= \frac{1 - \cos\theta}{2} \\ \sin\left(\frac{\theta}{2}\right) &= \pm\sqrt{\frac{1 - \cos\theta}{2}}\end{align*}
As you can see, the squares on the equation force it to take the plus-minus sign.
Edit: I don't have an idea about the $\displaystyle \mathrm{sgn}\left(2\pi - \theta + 4\pi\left\lfloor\frac{\theta}{4\pi}\right\rfloor\right)$. I just used the basic ones.
Edit: I understand what you are saying now. But I still do not understand how the notational trick incorporates the same.
– Aadi Prasad Apr 04 '21 at 08:39