Differentiability of $f(|x|)$
Solution 1:
For all $x>0$, the derivative of $f(|x|)$ equals $f'(x)$, and for all $x<0$, the derivatice of $f(|x|)$ equals $-f'(-x)$. Thus, $f(|x|)$ is differentiable (at $0$) if and only if $$\lim_{x\to 0^+}f'(x)=-\lim_{x\to 0^-}f'(-x).$$
If $f$ is continuously differentiable, above condition holds if and only if $f'(0)=0$.
This shows why your example of $f(x)=\cos x$ works: its derivative at $0$ is $-\sin 0=0$.
Further, any polynomial $f(x)$ with no linear term will also work. For instance, take $f(x)=3x^3-2x^2-5$.
Solution 2:
The condition for differentiability of $f(\lvert x\rvert)$ is if and only if $f$ is differentiable on $(0,\infty)$ and $\lim_{x\to 0^+}\frac{f(x)-f(0)}x=0$. In which case, $\frac{d}{dx}f(\lvert x\rvert)=\begin{cases}0&\text{if }x=0\\ -f'(\lvert x\rvert)&\text{if }x<0\\ f'(\lvert x\rvert)&\text{if }x>0\end{cases}$.
For the $[\Leftarrow]$ part, by chain rule the only issue is differentiablity at $0$. Then, $\lim_{x\to 0}\frac{f(\lvert x\rvert)-f(0)}x$ exists if and only if $\lim_{x\to0^+}\frac{f(\lvert x\rvert)-f(0)}x$ and $\lim_{x\to0^-}\frac{f(\lvert x\rvert)-f(0)}x$ exist and they are equal. Evidently, \begin{align}&\lim_{x\to0^+}\frac{f(\lvert x\rvert)-f(0)}x=\lim_{x\to0^+}\frac{f( x)-f(0)}x=0\\ &\lim_{x\to0^-}\frac{f(-x)-f(0)}x=\lim_{x\to0^+}\frac{f(x)-f(0)}{-x}=-\lim_{x\to0^+}\frac{f(x)-f(0)}{x}=0\end{align}
For the $[\Rightarrow]$ part, notice that $g:=f(\lvert\bullet\rvert)$ and $f$ coincide on $[0,\infty)$. For $x>0$ and sufficiently small $h$, $\lvert x+h\rvert=x+h$, therefore $f'(x)=g'(x)$ for all $x>0$. Moreover, $\lim_{x\to 0^+}\frac{f(x)-f(0)}x=\lim_{x\to 0^+}\frac{f(\lvert x\rvert)-f(0)}x$. We only need to prove that $g'(0)=0$ this is because $g$ is even, and by change of variable $$g'(x)=(g\circ(-id))'(x)=-g'(-x)$$ This implies $g'(0)=-g'(-0)=-g'(0)$.
$$$$ The final identity is fairly easy to prove with chain rule, more or less in the fashion that we've discussed for $g'(0)$.