Ah, I found the solution, it's just the mean value theorem.
By the mean value theorem we know that there exist points $\eta_1, \eta_2$ such that \begin{align} Df(\eta_1) = \frac{|f(A)|}{|A|}, \quad Df(\eta_2) = \frac{|f(B)|}{|B|} \end{align} Thus we have \begin{align} \frac{|f(B)|}{|B|} \Big/ \frac{|f(A)|}{|A|} = \frac{|Df(\eta_2)|}{|Df(\eta_1)|} \leq M, \end{align}\begin{align} \frac{|f(B)|}{|B|} \Big/ \frac{|f(A)|}{|A|} = \frac{|Df(\eta_2)|}{|Df(\eta_1)|} \leq e^M, \end{align} which rearranges to \begin{align} \frac{|A|}{|B|} \leq M \frac{|f(A)|}{|f(B)|}.\end{align}\begin{align} \frac{|A|}{|B|} \leq e^M \frac{|f(A)|}{|f(B)|}.\end{align}