So if we have
$y=x$ when $x \ne 1$ and
$y = 0$ when $x = 1$.
The inverse would be:
$y=x$ when $x \ne 0$ and
$y=1$ when $x = 0$
Yep. You correctly switched $x$ and $y$ and solved for $y$, and then switched the domain and range.
It’s just a bit more complicated than reflecting the graph about the line $y=x$, because the result may not be the graph of a function any more. Note that if you take your original picture and perform the reflection, there are two points in the new picture with $x$-coordinate $0$, and none with $x$-coordinate $1$.
The elaborate way of describing the situation is: consider a function $f\colon X\to Y$, $X$ being the domain of the function, and $Y$ being the target space. There is a left inverse $g\colon Y\to X$ satisfying $g(f(x))=x$ for all $x\in X$, if and only if the original $f$ was one-to-one. And there is a right inverse $h\colon Y\to X$ satisfying $f(h(y))=y$ for all $y\in Y$ if and only if $f$ was onto $Y$.
Examples with $X=Y=\mathbb R$: the exponential function $\exp(x)=e^x$ is one-to-one but not onto, and has this left inverse $g$: if $t>0$, $g(t)=\ln(t)$, while if $t\le0$, $g(t)=17$. The function $\tan^*$ cooked up from the tangent by setting $\tan^*(x)=\tan(x)$ if $x$ is not an odd multiple of $\pi/2$, and $\tan^*((k+1/2)\pi)=0$ is onto, and has the right inverse $h=\arctan$, the usual inverse tangent function. Notice that $g$ is not a right inverse of the exponential function any more than $h$ is a left inverse of the hoked-up tangent function.
The reflection of a line along the $x$-axis is the inverse IF the inverse of the original function is defined. A function is invertible if it passes the horizontal line test (so that its inverse will pass the vertical line test).