Lemma
For every \(S\)-scheme \(S'\),
\begin{align*} \Hom_{S'-gp}(\mathbb G_{m, S'}, \mathbb G_{m, S'}) = \{\text{locally constant functions }|S'|\to \mathbb Z\}, \end{align*}where \(|S'|\) is the underlying topological space of \(S'\). In other words, the restriction of \(\mathbb G_{m, S'} \to \mathbb G_{m, S'}\) to a connected component of \(S'\) corresponds to a monomial.
Proof
First reduce to the case that \(S' = \Spec A\). Then an endomorphism \(\phi:\mathbb G_{m, S'}\to \mathbb G_{m, S'}\) is an \(A\)-algebra map \(\phi^*:A[u^{\pm}]\to A[u^{\pm}]\) determined by \(\phi^*(u^{\pm}) = f\), and \(f\) is necessarily a unit because \(u\) is a unit. Write
\begin{align*} f = \sum_{n\in \mathbb Z} a_n u^n \end{align*}with almost all \(a_n = 0\).
The group law \(m:\mathbb G_{m, S'}\times \mathbb G_{m, S'} \to \mathbb G_{m, S'}\) corresponds to the comultiplication
\begin{align*} \Delta:A[u^{\pm}]\to A[u^{\pm}]\otimes_A A[u^{\pm}] = A[u^{\pm}, v^{\pm}], \quad \Delta(u) = u\otimes u = uv. \end{align*}The requirement that \(\phi\) is a homomorphism is the requirement that \(\phi\circ m = m\circ (\phi \times \phi)\), and the corresponding condition is then \(\Delta\circ \phi^* = (\phi^*\otimes \phi^*)\circ \Delta\), which can be checked on the generator \(u\):
\begin{align*} \Delta(\phi^*(u)) &= \Delta(f(u)) = f(uv) = \sum_{n\in \mathbb Z}a_nu^nv^n \\ &\text{must equal}\\ (\phi^*\otimes\phi^*)(u\otimes u) &= f(u)f(v) = \sum_{n, m\in \mathbb Z} a_na_mu^nv^m \end{align*}That is, \(f(uv) = f(u)f(v) \). Comparing coefficients means that \(a_na_m = 0\) whenever \(n \neq m\) and \(a_n = a_n^2\) whenever \(n = m\). This means that \(\{a_n\}_{n\in \mathbb Z}\) is a collection of “orthogonal idempotents” in \(A\).
The key general fact is then that orthogonal idempotents are open-closed decompositions. For an idempotent \(e\in A\), \(A \cong Ae \times A(1 - e)\) and \(\Spec A = D(e)\sqcup D(1- e)\), with \(D(e) = \Spec A/(e - 1)\). Note that the ideal \(Ae \) is a ring with \(e\) the identity, so we can actually write \(D(e) = \Spec Ae\) which is nice. If we instead have a finite complete system of idempotents \(\{a_n\}\) (“complete” meaning that \(1 - a_n\) appears in the collection for each \(a_n\)) then we get
\begin{align*} A = \prod_n Aa_n \quad\text{and}\quad \Spec A = \coprod_n S'_n, ~ S'_n := D(a_n). \end{align*}If we restrict to \(S'_n\) then \(\phi|_{S'_n}\) corresponds to \(\phi^*|_{Aa_n}(u) = u^n\), so on \(S'_n\) the map \(\phi \) is the \(n\)th power map. That is, it’s a monomial in \(u\).
Similarly, any morphism \(\phi:\mathbb G_{m, S'}\to \mathbb G_{m, S'}\) which corresponds to a monomial on each connected component of \(S'\) is a \(S'-gp\) homomorphism.