I’ll give a purely mathematical example that I often used with students beyond the elementary calculus level. (See last paragraph below regarding college algebra and precalculus level students.) At this level students will be encountering situations where they have to show (or be able to understand proofs) that certain definitions of a function are well defined (sometimes one says “give a well defined function”). Examples of this arise when working with quotient groups and quotient rings, when defining the group operation for the fundamental group in topology, when working with congruence classes in number theory, in various places in differential geometry (example 1 and example 2 and example 3), etc. Incidentally, while looking up these links I found the MSE question well-defined functions, which discusses the same type of example given below, and even has aspects very similar to my Observation (2) below, despite my having written that before seeing this other discussion.
Let $p$ and $q$ be integers, one or both nonzero if necessary.
Let $f$ be the “function” from the rationals to the integers defined by $f\left(\frac{p}{q}\right) = pq,\;$ or some variation such as $\;=p+q\;$ or $\;=p^2 – q.$ Incidentally, simplest would be to use $\;=p\;$ or $\;=q,\;$ but I think using a slightly more involved formula works better, especially when Observation (2) below is dealt with.
Note that $\frac{1}{2} = \frac{2}{4} = \frac{3}{6},$ but the formula for $f$ gives different outputs for these different representations of the number "one-half". Therefore, there is not a unique output for each input.
I can think of two useful observations that one can make with this example. Observation (1) Using a simple mathematical formula that otherwise seems unproblematic is not enough—the nature of the actual input elements matters. Specifically, we see that the distinction between a representation of the number “one-half” and the number itself actually matters. Observation (2) The “functionality” issue for this example can be investigated in the same way that is done in the actual situations that students will encounter, namely by showing that the output is independent of the choice of representation of the input. Specifically, the representations $\frac{p}{q}$ and $\frac{p’}{q’}$ correspond to the same number if and only if there exists $k \neq 0$ such that $p’ = kp$ and $q’ = kq.$ Thus, to be well defined (sometimes one says “single-valued” at this point), we require $f\left(\frac{p}{q}\right) = f\left(\frac{p’}{q’}\right),$ which is equivalent to the requirement that $pq = p’q’ = (kp)(kq) = k^2pq.$ However, because $k^2 \neq 1$ is possible, $f$ is not well defined.
Note that if we define $g\left(\frac{p}{q}\right) = \frac{p^2 \; + \; q^2}{pq},$ then $g$ is a function from the nonzero rationals to the rationals. One way to see this, which corresponds to using the approach of Observation (1) above, is to note that $\frac{p^2 \; + \; q^2}{pq} = \frac{p}{q} + \frac{q}{p},$ and thus we are actually dealing with the function $g(x) = x + \frac{1}{x}$ for nonzero rationals $x.$ Another way to see this, which corresponds to using the approach of Observation (2) above (this is what is typically done in practice in the case of quotient groups, the fundamental group operation, etc.), is to note that
$$ f\left(\frac{p'}{q'}\right) \; = \; f\left(\frac{kp}{kq}\right) \; = \; \frac{k^2p^2 + k^2q^2}{kp \cdot kq} \; = \; \frac{k^2(p^2 + q^2)}{k^2pq} \; = \; \frac{p^2 + q^2}{pq} \; = \; f\left(\frac{p}{q}\right) $$
These examples can also be used at the college algebra and precalculus level, and I’ve done this. I like to think of pictures with arrows and tables as a “right brain” approach and something like $f\left(\frac{p}{q}\right) = pq$ as a “left brain” approach. Of course, while some students at this level will be intrigued with the approach of Observation (1) above for $f\left(\frac{p}{q}\right) = pq$, you’ll definitely want to stay away from the symbolism involved in the approach of Observation (2).