Can a surjective function have an element in the domain not mapped to the codomain? I have seen a lot of definitions for surjectivity stating that every element in the codomain must be mapped to something in the domain. But does the opposite also have to hold true for a function to maintain its surjectivity?

No (to your title question), a function $f : A \to B$, by definition, gives each $x \in A$ a value $f(x) \in B$.
To be precise, you should have said that "for every element in the codomain, there is (at least) one element which is mapped to it by $f$" for your definition of surjectivity.
