As I mentioned in my comment, a good way to go is to prove the following lemma:
Lemma: Let $Y$ be a set. The following are equivalent:
- $Y$ is infinite.
- There exists an injective map $g: \mathbb{N} \rightarrow Y$.
- There exists a surjective map $h: Y \rightarrow \mathbb{N}$.
First, let's see how the lemma implies the result. If $X$ is finite, then there exists a bijection $f: X \rightarrow S$, where $S \subseteq \mathbb{N}$. We can then compose $f$ with the inclusion map $i : S \hookrightarrow \mathbb{N}$, which is automatically injective, to get the injective function $i \circ f: X \rightarrow \mathbb{N}$. Last, we follow up with the injective map $g$ from the lemma to get the injection $g \circ i \circ f : X \rightarrow Y$.
You can show there exists a surjective function $Y \rightarrow X$ in a similar way.
There are different levels of how rigorously you can prove the lemma, such as going to the Recursion Theorem, but maybe it's best to keep it elementary. (I had an argument here previously, but I cut it out for being overly confusing.) For example, to show (1) implies (2), just assume $Y$ is infinite and notice that given any sequence of distinct elements $f(1), f(2), \ldots, f(n)$ in $Y$, you can always find some $y$ not in this list, or else $Y$ would be finite. Define $f(n+1) = y$ and continue.
Best Answer
If the only thing you know about $X$ is that it is infinite, then it is not possible to describe such a mapping precisely enough that you can know what it does to each element. You don't even know what the elements are, so how would the example be able to tell what happens to them?
Using the Axiom of Choice, one can prove (see below) that every infinite $X$ has a subset $Y$ that is in bijective correspondence with $\mathbb N$. In that case you can construct $f$ as "for every element $x$ that corresponds to a natural number $n$, $f(x)$ is the element that corresponds to $n+1$; if $x$ doesn't correspond to a natural, $f(x)=x$.
Proof of above claim. Let $X$ be infinite; we want to construct a injection $\varphi:\mathbb N\to X$. Then the image of $\varphi$ will be the requested $Y$.
Fix a choice function $g:\mathcal P(X)\setminus\{\varnothing\}\to X$, and define $\varphi$ recursively: $$ \varphi(n) = g\bigl( X\setminus \{\varphi(i) \mid i<n\} \bigr) $$ The argument $X\setminus\{\varphi(i) \mid i<n\}$ is always non-empty because $X$ is infinite and there are only finitely many $\varphi(i)$ with $i<n$. So there are elements in $X$ that don't get removed.
Then $\varphi$ is injective: If $b>a$, then $\varphi(a)\ne\varphi(b)$ because $\varphi(b)$ will have been constructed as $g$ of a set where $\varphi(a)$ has explicitly been removed.
(Actually one needs only the axiom of Countable Choice, but that's a bit more involved -- see sketch by Asaf in the comments).