I don't know the exact type of generalization that you have in your mind. But since you said "in any sense", I will say a few things about the maximum possible generalization: Involutive Functions
An involution is a function $f: X\to X$ whose inverse is itself. That is, $$f\circ f=\operatorname{id}_X$$ A function is an involution if and only if the underlying relation is symmetric. When $X$ is a subset of $\mathbb{R},$ this fact can be seen as the graph of $f$ being symmetric around the line $y=x.$
The example gave you $$y=\dfrac{ax+b}{cx-a}$$ is an involution of $\mathbb{R}$ which can also extend easily to $\mathbb{R}\cup\{\infty\},$ or even to the Rienamm sphere $\mathbb{C}\cup\{\infty\}.$ And there are many more such functions. Another example is $$y=\dfrac{ax}{\sqrt{x^2-a^2}}.$$
Added Later:
Consider the function $a\mapsto 9a$ defined on $\mathbb{Z}_{20}$ (integers modulo $20$). It is not difficult to see that this is an involution. Likewise, in general, there are many exotic examples.