There is no such function.
Proof: For all $N \in \mathbb N$ and for each $y\in \mathbb R$, since $f(x) \to \infty$ as $x\to y$, there is $\delta_y >0$ so that
$$|f(x)|\ge M,$$
for all $x\in \mathbb R$ and $0<|y-x|<\delta_y$. Then
$$\{ ( y-\delta_y, y+\delta_y) : y\in \mathbb R\}$$
forms an open covering of $\mathbb R$, and thus has a countable subcover, which we called
$$\{ ( y_n-\delta_{y_n}, y_n+\delta_{y_n}) : n\in \mathbb N\}.$$
As a result, the set
$$\tag{1} \{ y\in \mathbb R : |f(y)|<N\}$$
is countable since it's inside $\{y_1, y_2, \cdots, y_n, \cdots\}$.
But this is impossible, since
$$ \bigcup_{N\in \mathbb N} \{ y\in \mathbb R : |f(y)|<N\} = \mathbb R$$
and $\mathbb R$ is uncountable.
Remark: This question is very similar, in essence, to this question, and the technique is similar.
Remark Another way to show that the set in (1) is countable is by contradiction: if it is uncountable, then it has a limit point $x\in \mathbb R$. By definition of a limit point, there are $y_n \to x$ so that $|f(y_n)|<N$. But that contradicts to the assumption that $f(y)\to \infty$ as $y\to x$.