$$\int{|\sin(x)+ \cos (x)|} \,\mathrm dx=
\begin{cases}
-\cos(x) +\sin(x) +C_1, & \text{if }\sin(x)+ \cos (x) > 0 \\
\cos(x) -\sin(x) + C_2, & \text{if }\sin(x)+ \cos (x)<0
\end{cases}$$
we need a function
$$
f(x) =
\begin{cases}
1, & \text{if $\sin(x)+ \cos (x) > 0$ } \\
-1, & \text{if $\sin(x)+ \cos (x)<0$}
\end{cases}
$$
So
$$f(x):=
\begin{cases}
0, & \text{if $x=k\pi -\frac{\pi}{4}$ for any integer $k$ } \\
\frac{\sin(x)+ \cos (x)}{|\sin(x)+ \cos (x)|}, & \text{otherwise}
\end{cases}
$$
This gives
$$\int{|\sin(x)+ \cos (x)|} \,\mathrm dx = (-\cos(x) +\sin(x))f(x) +C
$$
btw there is a function that behave like $f(x)$ which is $\operatorname{sgn}(x)$.
$$\operatorname{sgn}(x):=
\begin{cases}
0, & \text{if $x=0$ } \\
\frac{x}{|x|}, & \text{otherwise }
\end{cases}$$
then $f(x)=\operatorname{sgn}(\sin(x)+ \cos (x))$ so the antiderivative is
$$
(-\cos(x) +\sin(x))\operatorname{sgn}(\sin(x)+ \cos (x))+C.
$$