So I read from various sources that a function can be defined as a binary relation. Then is it valid to say, for example, $f = \{ (1, 2), (2, 3) \}$?
And suppose I have another function $g = \{ (4, 5) \}$. Does it then make sense to write $(f \cup g)(2) = 3$?
In the language of set theory, using the standard representation of function as sets of pairs, you are exactly right. Your $f$ and $g$ are both functions, as is $f \cup g$, and $(f \cup g)(2)=f(2) = 3$.
In general, the union of any two functions $f$ and $g$ is a function provided they agree on the intersection of their domains: i.e., provided that for any $x$, $y$ and $z$, if $(x, y) \in f$ and $(x, z) \in g$, then $y = z$.