Can the idea of a 'function of a variable' be made rigorous?

When we say “$y=f(x)$”, we are stating a typographical convention that we are going to adopt in the present context: Namely, whenever the letters $x$ and $y$ appear, the values to which they refer are connected by the functional relationship $f$. The terminology “$y$ is a function of $x$” is confusing. While it is still employed by many people who use mathematics, it is often avoided by present-day mathematicians, who are aware that $y$ and $f$ refer to quite different types of mathematical object.

For example, consider the function $$f:\Bbb R\to\Bbb R_{\geqslant0}:x\mapsto f(x):= x^2.$$ In this case, $f$ may be identified with a certain subset of $\Bbb R\times\Bbb R_{\geqslant0}$. Quite separately, and in addition, we may adopt the naming convention of using $y$ instead of $f(x)$. But $y$ is just some element of $\Bbb R_{\geqslant0}$, albeit dependent on $x$, while $f$ is a quite particular subset of $\Bbb R\times\Bbb R_{\geqslant0}$ (which determines the relationship between $x$ and $y$).

In this context, the notation “$y=y(x)$” is often used, which further reinforces the confusion between $y$ and $f$. This sort of notation may be convenient for (say) practical engineering calculations, but it's not a good place to start when you want to maintain a clear mathematical concept of function.

In the above, for simplicity, I have adopted the convention of identifying a function with its graph. In some branches of mathematics this is inconvenient, and to specify a function it is necessary to specify a codomain for it (of which the range of the function is a subset).