Well, this is true if $R$ is commutative and noetherian; I don't know whether that's good enough for what you want. (This solution may be overcomplicated; I do not actually know how to prove all the facts I am using.)
If $R$ is commutative, noetherian, and self-injective, then it's Artinian, it's a finite product of local Artinian rings, hence we can reduce to the local case.
So say $R$ is commutative, noetherian, and local (and hence Artinian, but I won't use that). Take an injective hull of $M$ inside $R^n$; call it $Q$. So $f$ extends injectively to $f:Q\rightarrow R^n$, and we now need to extend it from $Q$ to all of $R^n$. Since $Q$ is injective, it is a direct summand of $R^n$, and hence is also projective. But we assumed $R$ was local, and hence $Q$ is free; say it is isomorphic to $R^m$, $m\le n$.
Then an injective function $R^k \rightarrow R^n$ is the same as an (ordered) linearly independent subset of $R^n$, of $k$ elements. So we have $m$ linearly independent elements of $R^n$ and we want to extend it to $n$ such. We can extend it to a maximal linearly independent set, certainly; the question then is just if such a set necesssarily has $n$ elements.
Now, since we assumed $R$ was commutative and noetherian, we can apply the theorem of Lazarus quoted here, and say yes, a maximal linearly independent set of $R^n$ necessarily has $n$ elements, and so having extended $f$ to $Q\cong R^m$, we can further extend it to $R^n$.