\frac{d}{dx}|\cos(x)|=-\frac{|\cos(x)|}{\cos(x)}\sin(x)
Note that the signum function can be defined by sgn(x)=\frac{|x|}{x} for nonzero x, and is zero when x is zero. The signum function cannot be use in this case as |\cos(x)| is not differentiable at the values of x for which \cos(x)=0 as the lefthand and righthand derivative are not equal there (by lefthand or righthand derivates, what is meant is the left or right-handed limit of the difference quotient at a particular value of x).