We construct models of Einstein and fðRÞ gravity with two scalar fields, which admit analytical solutions describing time-varying dynamical black holes. Their thermodynamics is investigated in the adiabatic approximation. In addition to the Misner-Sharp-Hernandez quasilocal mass, we provide timedependent thermodynamical quantities, including the Hawking temperature, Helmholtz free energy, entropy, and thermodynamical energy. The latter does not always coincide with the Misner-Sharp-Hernandez mass at the horizon, although they coincide in the static limit. For Schwarzschild-type (i.e., g tt g rr ¼ −1) black holes in Einstein gravity, one of the two scalars is always a ghost with negative kinetic energy. We show that this ghost can be avoided in fðRÞ gravity.