Yes. Suppose that $f(x)$ is not a.e. constant. Then there is some subset $X$ of $\mathbb{R}$ such that $A:=f^{-1}(X)$ has positive measure but not full measure (we can take $X=(-\infty,x]$ for some adequate $x\in\mathbb{R}$).

Note that for all $d\in D$, $\mu(A\mathbin\Delta(A-d))=0$. Also, as $A$ and $\mathbb{R}\setminus A$ have positive measure, by the [Lebesgue density theorem](https://en.wikipedia.org/wiki/Lebesgue%27s_density_theorem) there are two points $x,y$ such that, for some small value of $\varepsilon$, $\mu(A\cap(x-\varepsilon,x+\varepsilon))>1.5\varepsilon$ and $\mu(A\cap(y-\varepsilon,y+\varepsilon))<0.5\varepsilon$.

However, there is a sequence $(d_n)_n$ in $D$ such that $x+d_n\to y$. And for all $n$ we have 
$$\mu(A\cap(x+d_n-\varepsilon,x+d_n+\varepsilon))=\mu((A-d_n)\cap(x-\varepsilon,x+\varepsilon))$$
$$=\mu(A\cap(x-\varepsilon,x+\varepsilon))>1.5\varepsilon.$$

Thus, $\mu(A\cap(y-\varepsilon,y+\varepsilon))=\lim_{n\to\infty}\mu(A\cap(x+d_n-\varepsilon,x+d_n+\varepsilon))\geq1.5\varepsilon$, a contradiction.


**Edit:** It seems this argument works more generally, e.g. if $G$ is a locally compact group with $\sigma$-finite Haar measure and a measurable function $f:G\to\mathbb{R}$ satisfies that for all $d$ in some subset $D$ dense in $G$ we have $f(dx)=f(x)$ a.e., then $f$ is a.e. constant. To use the argument above in the general case one would need to use some version of the Lebesgue density theorem for locally compact groups, see e.g. Theorem A in the article "[Three Results for Locally Compact Groups Connected with the Haar Measure Density](https://doi.org/10.2307/2035942)", by Mueller.