While reading this result (which claims continuity but actually proves uniform continuity), I wondered how do such functions (on $\mathbb R$) look like?
For a singleton set $\{a\}$, it would be $|x-a|$.
This is easily extended to all finite sets: for a finite set $\{a_1,a_2,\dots,a_n\}$ (where $a_i<a_{i+1}\:\forall\:i$). The function will be $$f(x)=\begin{cases} |x-a_1|&\text{ if }x\le\frac{a_1+a_2}2\\ |x-a_2|&\text{ if }\frac{a_1+a_2}2<x\le\frac{a_2+a_3}2\\ \ \,\quad\vdots&\\ |x-a_{n-1}|&\text{ if }\frac{a_{n-2}+a_{n-1}}{2}<x\le\frac{a_{n-1}+a_n}{2}\\ |x-a_n|&\text{ if }x>\frac{a_{n-1}+a_n}2 \end{cases}$$ So the graph of this function would be like $|x|$ at the ends, with lots of zig-zag lines in the middle (unlike a single sharp point like that in $|x|$).
Countable sets may go similarly, like for integers we get infinitely many zig-zag lines.
But it may also be different for some countable sets, like it is constant $0$ function for rationals.
For bounded intervals, we get the absolute value functions towards the end and constant $0$ function in the middle. For unbounded intervals, it is absolute value function on one side and $0$ on the other (except for $(-\infty,\infty)$, for which it is constant $0$ throughout).
Union of intervals can be managed similarly, and I suppose all open sets will work similarly, because they are countable union of disjoint open intervals.
And then, I thought of Cantor set and got stuck. It is easy to see that the function is $|x|$ before zero and $|x-1|$ after $1$, but what happens inside the unit interval, that I could not see (since the cantor set is also not dense like the set of rationals, the distance is $\frac16$ for $\frac12$).
Let $C$ denote the Cantor set. It will suffice to understand how $f(x) = d(x,C)$ behaves when restricted to $[0,1] \setminus C$. Recall we may construct the Cantor set as $C = \bigcap_{n} C_n$, where $C_0 = [0,1]$, and $C_{n+1}$ is constructed from $C_n$ by removing $2^{n-1}$ open intervals. Let $I^n_1, \cdots, I^n_{2^{n-1}}$ denote the open intervals removed from $C_n$ to build $C_{n+1}$. Then we may write: $$[0,1] \setminus C = \bigcup_{n \in \mathbb{N}} \bigcup_{m=1}^{2^{n-1}} I_m^n$$ Since the $I_m^n$ are all disjoint, it will suffice to understand the behavior of $f$ on each of these intervals. Let $a^n_m < b^n_m$ denote the left and right endpoints of $I_m^n$. For $x \in I_m^n$ it is clear that $d(x, C) = min \{ d(x, a_m^n), d(x, b_m^n) \}$. And so we have: $$f \big \rvert_{I_m^n}(x) = \frac{b_m^n-a_m^n}{2} - \left | x - \frac{b_m^n + a_m^n}{2} \right |$$ Letting $\chi_A$ denote the characteristic function on a set $A$, we see that: $$f \big \rvert_{[0,1]}(x) = \sum_{n=1}^\infty \sum_{m=1}^{2^{n-1}} \left [\frac{b_m^n-a_m^n}{2} - \left | x - \frac{b_m^n + a_m^n}{2} \right | \right ] \cdot \chi_{I_m^n}(x)$$ Since the endpoints of the removed intervals can be derived by hand, I leave the rest to you.