Ab initio nonperturbative calculation of physical observables in light-front dynamics. Application to the Yukawa model