$y = \pm |y| = \pm (1 - |x|)$ for $-1 \le x \le 1$.
That is, there are two cases: $+(1 - |x|)$ which gives you the top half of your square, and $-(1-|x|)$ which gives you the bottom half.
Those inequalities are necessary, because $|y|$ is not allowed to be negative.
https://www.desmos.com/calculator/8xizt66y8k
Here's my solution.
The idea is to use an absolute value expression as a coefficient for each line you want, and have that expression equal zero when you dont want that line's value.
$\frac{\left(\left|x-a\right|+x-a\right)}{2\left(x-a\right)}$ will be equal to 1 when $x>a$, and 0 when $x<a$
$\frac{\left(\left|a-x\right|+a-x\right)}{2\left(a-x\right)}$ will be equal to 1 when $x<a$, and 0 when $x>a$
so
$\frac{\left(\left|x-a\right|+x-a\right)}{2\left(x-a\right)}\frac{10}{10-a}(x-a)+\frac{\left(\left|a-x\right|+a-x\right)}{2\left(a-x\right)}\frac{-10}{0-a}(x-a)$ will be equal to $\frac{10}{10-a}(x-a)$ when $x>a$, and will be equal to $\frac{-10}{0-a}(x-a)$ when $x<a$
hope that helps!
Note: This is undefined for $x=a$,but in that case $y=0$ anyway. Also it is undefined for $a=0$ and $a=10$, but it was that way for your original piecewise function anyway.
edit: there might be a better solution to this, but this is what I could come up with off the top of my head.I'd love to see something prettier though.
Best Answer
You graph this equation manually the same way you graph any equation: try to find enough solution points to give you a feel for how the equation behaves, and interpolate the rest. When possible, use what you know about the functions to reduce the number of points needed.
In this case, you should know what $y=|x|$ looks like, which tells you that your equation is going to consist of line segments with vertices at places where the interior of the absolute values is $0$.
It is helpful to solve it for $y$: $$|y - 2| = 3 - | 1 - |x|\,|\\y = 2\pm(3 - | 1 - |x|\,|)$$ Which also tells you that the graph will be symmetric about the line $y = 2$, and since $x$ only appears inside the absolute value, the graph will also be symmetric about $x = 0$.
If we examine just the quadrant where $x \ge 0$ and $y \ge 2$, we have $$y = 5 - |1 - x|$$ For $x \le 1, y = 5 - (1 -x) = 4 + x$. For $x \ge 1, y = 5 + (1 - x) = 6 - x$ Note that since $y \ge 2$ in this quadrant, this only holds when $6 - x \ge 2$, thus $x \le 4$. So in this quadrant, this is the graph of $$y = \begin{cases} 4 + x& 0\le x \le 1\\6 -x & 1 \le x \le 4\end{cases}$$
Reflect that graph through $x = 0$, and then reflect again though $y = 2$ to get the full graph.