Endomorphisms of forgetful functor $\mathbf{Grp}\to \mathbf{Set}$
Your proof is correct. Here is a shorter proof using the Yoneda Lemma (actually you have proven the Yoneda Lemma in a special case, we do this all the time without knowing it):
The functor $U$ is representable by $\mathbb{Z}$ (since an element of a group is the same as a homomorphism from $\mathbb{Z}$). Hence, the Yoneda Lemma tells us $$\mathrm{Hom}(U,U) \cong \mathrm{Hom}(\mathrm{Hom}(\mathbb{Z},-),U) \cong U(\mathbb{Z}),$$ the set of integers.
More generally, if $C$ is any variety of algebraic structures with forgetful functor $U : C \to \mathsf{Set}$, then $\mathrm{Hom}(U^n,U)$ corresponds to the underlying set of the free $C$-algebra on $n$ generators. You may imagine these as "universal $n$-ary operations". For example, for $C=\mathsf{Ring}$ and $n=2$ such an operation is $x^2 - xy + y^2$.
More interesting things happen for non-algebraic categories. For example, consider the forgetful functor $U : \mathsf{FinGrp} \to \mathsf{Set}$ from the category of finite groups. Here, $U$ is not representable, but it is ind-representable: We have a canonical isomorphism $$U \cong \varinjlim_n \,\mathrm{Hom}(\mathbb{Z}/n,-)$$ Therefore: $$\mathrm{Hom}(U,U) \cong \varprojlim_n \,\mathrm{Hom}(\mathrm{Hom}(\mathbb{Z}/n,-),U) \cong \varprojlim_n U(\mathbb{Z}/n),$$ which is the underlying set of the pro-finite completion $\widehat{\mathbb{Z}}$. If $(\overline{z_n})_n$ is an element in $\widehat{\mathbb{Z}}$, the corresponding operation on finite groups maps an $n$-torsion element $g$ to $g^{z_n}$. This is well-defined precisely because we have $z_n \equiv z_m \bmod n$ for $n | m$. We get the same results when we work with the larger category of torsion groups.
In general, if you want to determine $\mathrm{Hom}(U,U)$ for any functor, try to write $U$ as a colimit of representable functors $\mathrm{Hom}(X_i,-)$ (this is always possible, though in general somewhat tautological), then $\mathrm{Hom}(U,U)$ is the limit of the $U(X_i)$.