We introduce a density functional-based formalism to compute the electrostatic energy and forces for a mesoscopic system in the condensed phase, described with molecular resolution. The dielectric permittivity is variable in space, and it is dependent on the density fields of the individual particles present in the system. The electrostatic potential is obtained from standard numerical solutions of the generalized Poisson equation. The presence of a particle-dependent varying dielectrics produces the appearance of mesoscopic polarization forces, which are dependent on the local fluctuations of the permittivity, as well as of the electrostatic field. The proposed implementation is numerically robust, with an error on the Coulomb forces that can be systematically controlled by the mesh of spatial grid used for solving the generalized Poisson equation. We show that the method presented here is able to reproduce the concentration-dependent partitioning of an ideal salt in water/oil mixtures, in particular, reproducing the 1/ϵ dependency of the partition coefficient for the free ions predicted by Born theory. Moreover, this approach reproduces the correct electrostatic features of both dipolar and charged lipid bilayers, with positive membrane and dipole potentials. The sum of both Coulomb and polarization interactions inside the membrane yields a globally repulsive potential of mean force for the ions, independently on their charge. The computational efficiency of the method makes it particularly suitable for the description of large-scale polyelectrolyte soft-matter systems.