$\DeclareMathOperator\Hom{Hom}$The question is in the title. If the isomorphism $\Hom(A, G) \cong \Hom(B, G)$ is natural in $G$ then this is just the Yoneda Lemma. If $A$ and $B$ are finitely generated this is also true by the structure theorem.

However this sounds like it should be false in general, else it would imply by Yoneda that if $\Hom(A, -)$ and $\Hom(B, -)$ are (a priori not naturally) isomorphic, then they are also isomorphic in a natural way (though possibly by a different set of isomorphisms).

The question of course immediately generalizes to $R$-modules.

**Edit:** *Some context (that isn't really relevant for the question)*

I'm interested in this question in light of the universal coefficient theorem for Cohomology. A positive answer would imply that knowing all Cohomology groups of a space, *with arbitrary coefficients*, would already determine its Homology (although I think it is conceivable that this topological statement can be proven in a different way).

2more comments