I stumbled upon the following theorem in Dummit and Foote’s Abstract Algebra, Section 10.5:
Theorem 28. Let $D$, $L$, $M$, and $N$ be $R$-modules. If $$ 0 \longrightarrow L \xrightarrow{\enspace \psi \enspace} M \xrightarrow{\enspace \varphi \enspace} N \longrightarrow 0 $$ is exact, then the associated sequence $$ 0 \longrightarrow \mathrm{Hom}_R(D, L) \xrightarrow{\enspace \psi' \enspace} \mathrm{Hom}_R(D, M) \xrightarrow{\enspace \varphi' \enspace} \mathrm{Hom}_R(D, N) \tag{10} $$ is exact. A homomorphism $f \colon D \to N$ lifts to a homomorphism $F \colon D \to M$ if and only if $f ∈ \mathrm{Hom}_R(D, N)$ is in the image of $\varphi'$. In general $\varphi' \colon \mathrm{Hom}_R(D, M) \to \mathrm{Hom}_R(D, N)$ need not be surjective; the map $\varphi'$ is surjective if and only if every homomorphism from $D$ to $N$ lifts to a homomorphism from $D$ to $M$, in which case the sequence $(10)$ can be extended to a short exact sequence.
The sequence $(10)$ is exact for all $R$-modules $D$ if and only if the sequence $$ 0 \longrightarrow L \xrightarrow{\enspace \psi \enspace} M \xrightarrow{\enspace \varphi \enspace} N $$ is exact.
Let $R$ be a ring with $1$, not necessarily commutative. Let $D, L, M$ and $N$ be $R$-modules. If the sequence $$ 0 \longrightarrow \operatorname{Hom}_R(D, L) \xrightarrow{\enspace g_* \enspace} \operatorname{Hom}_R(D,M) \xrightarrow{\enspace h_* \enspace} \operatorname{Hom}_R(D, N) $$ is exact for all $R$-modules $D$, then $0 \to L \xrightarrow{g} M \xrightarrow{h} N$ is exact.
First observation is that since $R$ is not commutative, $\operatorname{Hom}_R(D, L)$ is generally not an $R$-module. So in general, the exact sequence of the homomorphisms is an exact sequence of abelian groups. But when I saw the proof, it used the fact that when using $R$ as an $R$-module instead of arbitrary $D$, $\operatorname{Hom}_R(R, L)$ is an $R$-module and also $\operatorname{Hom}_R(D, L) \cong L$ as $R$-module isomorphism. This part is clear to me.
My question is the following: If we consider $0 \to L \xrightarrow{g} M \xrightarrow{h} N$ to be an exact sequence of only the underlying structure of abelian groups, I understand why the theorem is true, but if the consequence is an exact sequence of modules, I don’t see how this result is true. I don’t see a straightforward way to convert $g_*$ from a group homomorphism into an $R$-module homomorphism $\operatorname{Hom}_R(R, L) \to \operatorname{Hom}_R(R, M)$.
Edit: I need to be clearer about my question. My question is, for whoever is familiar with the theorem, what is the formulation of the theorem? Do we talk about the latter exact sequence as a sequence of modules or a sequence of groups? If it is a sequence of modules, then how can I prove it?
Let $M,N,P$ be $R$-modules ($R$ unital, but necessariliy commutative) then $\hom_R(M,N)$ is a priori only an abeliean group (=$\mathbb{Z}$-module). I will provide a (partial) proof of your claim, namely that $$0\to M \xrightarrow{f} N \xrightarrow{g} P \tag{1}$$ is exact iff for all $R$-modules $D$ the sequence $$0\to \hom_R(D,M) \xrightarrow{f_*} \hom_R(D,N)\xrightarrow{g_*} \hom_R(D,P)\tag{2}$$ is exact.
Assume (1). First we'll show that $f_*$ is injective. We have that $$\ker(f_*)=\ker(\hom_R(D,M)\to \hom_R(D,N))\cong\hom_R(D,\ker(M\to N))=0$$ (the isomorphism can either be computed directly or can be seen abstractly because the functor $\hom_R(D,-)$ commutes with arbitrary limits). As $g\circ f=0$ we have $g_* \circ f_* =0$, so $\operatorname{im} f_* \subset \ker g_*$ by functoriality of $\hom_R(D,-)$. Let $h\in \ker(g_*)\subset \hom_R(D,N)$, i.e. $g\circ h=0$, so for all $d\in D$ we have $h(d)\in \ker g=\operatorname{im}f$; pick $m_d\in M : f(m_d)=h(d)$ for $d\in D$ and define $\phi:D\to M, d\mapsto \phi(d):= m_d$. As $f$ is injective the $m_d$'s are unique. We claim that $\phi$ is $R$-linear. Indeed, let $\mu\in R, d,d'\in D$. By construction and $R$-linearity of $f$ and $h$ we get: $$f(\phi(d+\mu d'))=h(d+\mu d')=h(d)+\mu h(d')=f(\phi(d)+\mu \phi(d')),$$ whence $\phi(d+\mu d')=\phi(d)+\mu \phi(d')$, since $f$ is injective.
Assume (2). Take $D=R$ in (2). This yields (1).