There is no such function.
Suppose $f: \mathbb R^m \rightarrow \mathbb R^n$ is a function with $\Gamma_f$ closed in $\mathbb R^{m+n}$. For each $i \in \mathbb N$, let $K_i = f^{-1}([-i,i]^n)$.
I claim that each $K_i$ is closed and nowhere dense in $\mathbb R^m$.
$K_i$ is closed because it is the projection onto $\mathbb R^m$ of the set $\Gamma_f \cap (\mathbb R^m \times [-i,i]^n)$, which is closed in $\mathbb R^m \times [-i,i]^n$, and the projection of a closed subspace of $X \times Y$ onto $X$ is always closed when $Y$ is compact.
To see that $K_i$ is nowhere dense, suppose $C$ is a closed subset of $K_i$. Notice that $\Gamma_f \cap (C \times [-i,i]^n)$ is closed in $C \times [-i,i]^n$, and it is the graph of the function $f \!\restriction\! C$. In particular, $f \!\restriction\! C$ is a function into a compact Hausdorff space, and $\Gamma_{f \restriction C}$ is closed. By the closed graph theorem (the one alluded to in the question), $f \!\restriction\! C$ is continuous. This implies that $K_i$ is nowhere dense: otherwise (because we already know $K_i$ is closed) there is a closed ball $C \subseteq K_i$, in which case $f \!\restriction\! C$ is a continuous injection from a topological copy of $[0,1]^m$ into $[0,1]^n$. As the OP already mentioned, this is impossible. (This is because a continuous injection on $C$ would be an embedding (because $C$ is compact), and one cannot embed $[0,1]^m$ into $[0,1]^n$ when $m > n$.)
The Baire Category Theorem now provides us with a contradiction. Because each $K_i$ is nowhere dense, it is impossible to have $\mathbb R^m = \bigcup_{i \in \mathbb N}K_i$. On the other hand, $\mathbb R^m = \bigcup_{i \in \mathbb N}K_i$ is implied by the definition of the $K_i$.