In this paper we consider a mass optimization problem in the case of scalar state functions, where instead of imposing a constraint on the total mass of the competitors, we penalize the classical compliance by a convex functional defined on the space of measures. We obtain a characterization of optimal solutions to the problem through a suitable PDE. This generalizes the case considered in the literature of a linear cost and applies to the optimization of a conductor where very low and very high conductivities both have a high cost, and then the study of nonlinear models becomes relevant.