Solution (source code)

= Solution

An isolated point outside $B$ cannot belong to its closure. Thus the only possible extra closure point is $a$. The balls at $a$ meet $B$ exactly when arbitrarily small original-metric balls at $a$ do so. Consequently
$$
\boxed{\overline B^{\,d_a}=\begin{cases}B,&a\in B,\\B,&a\notin B,\ d(a,B)>0,\\B\cup\{a\},&a\notin B,\ d(a,B)=0.\end{cases}}
$$
In the first case $a$ is already included. In the second case a ball smaller than the positive distance separates it from $B$; in the last case every ball meets $B$. If $B$ is empty its closure is empty, with distance convention $d(a,\varnothing)=+\infty$.