I am trying to calculate the derivative of $\left| \sin x \right| $
Given the graphs, we notice that the derivative of $\left| \sin x \right|$ does not exist for $x= k\pi$.
Graph for $\left|\sin x\right|$:
We can rewrite the function as
$\left| \sin(x) \right| = \left\{ \begin{array}{ll} \sin(x),& 2k\pi < x < (2k+1)\pi \\ -\sin(x), & \text{elsewhere} \\ \end{array} \right. $
Therefore calculate its derivative as:
$(\left| \sin(x) \right|)^{'} = \left\{ \begin{array}{ll} \cos(x),& 2k\pi < x < (2k+1)\pi \\ -\cos(x), & \text{elsewhere} \\ \end{array} \right. $
Is there a way to rewrite this derivative, in a more elegant way (as a non-branch function) $(\left| \sin(x) \right|)^{'} = g(x)$?

The better way, for me, is as follows: $$f(x)=\left|\sin(x)\right|=\sqrt{\sin^2(x)}$$ Now, differentiate both sides to get $$f'(x)=\frac{1}{2\sqrt{\sin^2(x)}}\cdot2\sin(x)\cos(x)=\frac{\sin(2x)}{2\left|\sin(x)\right|}$$ Therefore, $$\left(\left|\sin(x)\right|\right)'=\frac{\sin(2x)}{2\left|\sin(x)\right|}, \ \ \ \ x \neq k\pi, k\in \mathbb{Z}$$
Appendum: This approach can easily be extended to a general case of finding $\left(|f(x)|\right)'$.
First, we rewrite $$|f(x)| = \sqrt{f^2(x)}$$ Then, repeating the work above: $$|f(x)|' = \frac{1}{2\sqrt{f^2(x)}}[2f(x)f'(x)] = \frac{f(x)}{|f(x)|}f'(x)$$ we get $$\boxed{|f(x)|' = \frac{f(x)}{|f(x)|}f'(x)}$$