Compact surfaces with non-negative Euler characteristic cannot carry such metrics because of Gauss-Bonnet. However, this is the only obstruction.
First, such metrics exist on any compact orientable surface of genus greater than 1. For example, let $M$ be a hyperelliptic Riemann surface of genus $g\ge 2$, and let $\omega_1,\ldots,\omega_g$ be a basis for the holomorphic $1$-forms on the surface. Then the Riemannian metric
$$
g = \omega_1\circ\overline{\omega_1} + \cdots + \omega_g\circ\overline{\omega_g}
$$
has Gaussian curvature $K$ that is negative everywhere except at the Weierstrass points (of which there are $2g{+}2$), where it vanishes.
Second, one can construct such metrics on non-orientable surfaces with negative Euler characteristic: Consider a hyperelliptic Riemann surface $S$ of genus $g>1$ that has a fixed-point-free, anti-holomorphic involution $\iota$ with the property that there exists a basis $\omega_1,\ldots,\omega_g$ as above for which $\iota^*\omega_k = \overline{\omega_k}$. (Such examples exist for each $g>1$.) Then the above metric $g$ is invariant under $\iota$ and hence descends to be a metric with the desired properties on the non-orientable surface that one obtains by quotienting $S$ by the $\mathbb{Z}_2$-action generated by $\iota$. Since this construction can be done for each $g>1$, this gives a sequence of non-orientable compact examples covering all negative Euler characteristics.