A fluctuation–dissipation approach to dynamical friction in non-homogeneous backgrounds