You have to split it into cases.
If $x-a<0\implies x<a$, then $|x-a|=-(x-a)$:
$$\int|x-a|\,dx=-\int(x-a)\,dx=-\frac{x^2}{2}+ax+C.$$
If $x-a=0\implies x=a$, then $|x-a|=0$:
$$\int|x-a|\,dx=\int 0\,dx=K.$$
If $x-a> 0\implies x> a$, then $|x-a|=x-a$:
$$\int|x-a|\,dx=\int(x-a)\,dx=\frac{x^2}{2}-ax+M.$$
As you can see, the antiderivative is a piecewise-defined function. Moreover, the fact that at $x=a$ the antiderivative is $K$ means that the original function is differentiable there and therefore continuous at that point. This simply means that the curve should not have a gap there So, you just need to find appropriate values for $C$ and $M$ that depend on $K$ to make the curve continuous at $x=a$. You do that by solving these equations for $C$ and $M$ respectively: $-\frac{a^2}{2}+a\cdot a+C=K$ and $\frac{a^2}{2}-a\cdot a+M=K$.
Finally, this is the antiderivative:
$$
f(x)=
\begin{cases}
-\frac{x^2}{2}+ax+K-\frac{a^2}{2},\ x<a\\
K,\ x=a\\
\frac{x^2}{2}-ax+K+\frac{a^2}{2},\ x> a.
\end{cases}
$$