A new type of wave–mean flow interaction is identified and studied in which a small-amplitude, linear, dispersive modulated wave propagates through an evolving, nonlinear, large-scale fluid state such as an expansion (rarefaction) wave or a dispersive shock wave (undular bore). The Korteweg–de Vries (KdV) equation is considered as a prototypical example of dynamic wavepacket–mean flow interaction. Modulation equations are derived for the coupling between linear wave modulations and a nonlinear mean flow. These equations admit a particular class of solutions that describe the transmission or trapping of a linear wavepacket by an unsteady hydrodynamic state. Two adiabatic invariants of motion are identified that determine the transmission, trapping conditions and show that wavepackets incident upon smooth expansion waves or compressive, rapidly oscillating dispersive shock waves exhibit so-called hydrodynamic reciprocity recently described in Maiden et al. (Phys. Rev. Lett., vol. 120, 2018, 144101) in the context of hydrodynamic soliton tunnelling. The modulation theory results are in excellent agreement with direct numerical simulations of full KdV dynamics. The integrability of the KdV equation is not invoked so these results can be extended to other nonlinear dispersive fluid mechanic models.