Schwinger-Keldysh approach to out-of-equilibrium dynamics of the Bose-Hubbard model with time-varying hopping