I'm using the definition that well-defined means $x = y$ implies $f(x) = f(y).$
The reason I am confused is I wonder what is defined as 'equal' in the set of rationals. Obviously $f(1/2) = 1$ and $f(2/4) = 2$ and $2/4 = 1/2$ so it shouldn't be well-defined. However, I am unsure if $1/2$ and $2/4$ are considered the 'same' element in $\mathbb{Q}$ or not. Because if they are not, then $1/2\ne 2/4$ under such a framework.
$1/2$ and $2/4$ are indeed the same element of the rationals. Since they don't map to the same thing, the map is not well-defined.
The concern you ultimately have here is that $f(a/b)$ is dependent upon the visual presentation of the input and not necessarily its value: a common disqualifier when it comes to well-definedness. $1/2$ and $2/4$ are the same element, and have the same value, but are simply different ways to denote that value.
An example with a similar spirit is just the function $f : \mathbb{R} \to \mathbb{R}$ defined by
$$f(x) = \text{the second decimal digit to the right of the decimal point in $x$}$$
For instance, $f(1.367) = 6$ and $f(1.4941) = 9$.
But consider: $f(1) = f(1.000\cdots) = 0$, naturally, but $f(0.999\cdots) = 9$. Yet $1 = 0.999 \cdots$, so we should be getting the same output.
(And this is before we discuss other potential issues, e.g. what base should we represent the input in? The above all seem to work for base $10$ but what of base $2$, for instance?)