Galilean invariance is usually violated in self-consistent mean-field calculations that employ effective density-dependent nuclear forces. We present a novel approach, based on variational quantum Monte Carlo techniques, suitable to preserve this symmetry and assess the effect of its violation, seldom attempted in the past. To this aim, we generalize the linear optimization method to encompass the density-dependence of effective Hamiltonians, and study 4He, 16O, and 40Ca ground-state properties employing the Gogny interaction.