The theorem you stated can be true only for genus zero (that is for the sphere), if $K(x)<0$ at some point $x$); this follows from the Gauss Bonnet theorem that integral of the curvature $-K$ is equal to the Euler characteristic. For the conditions of solvability of your equation in this case, see Kazdan, Jerry L.; Warner, F. W. Curvature functions for compact 2-manifolds. Ann. of Math. (2) 99 (1974), 14–47. To obtain such metrics on surfaces of higher genus, one has to permit conic singularities of the metric. This is a hot research topic nowadays, and there is a <a href="https://www.math.purdue.edu/~eremenko/dvi/survey.pdf">recent survey</a>.