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. It is called the Nierenberg problem, and the complete answer is not known.

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.

For recent surveys, see https://arxiv.org/pdf/1411.5743.pdf
and https://arxiv.org/pdf/1707.02938.pdf

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>.