the image of $1$ by a homomorphism between unitary rings
As you correctly proved, it's true when $S$ is an integral domain.
Another fact is that if the homomorphism is surjective, then $\phi(1_R)$ is the identity in $S$, regardless of what $S$ is like. To prove it just check what it does to any other element of $S$.
Also true: if $R$ and $S$ are non-trivial rings, $S$ has an identity $1_S$, $\phi$ is injective and $1_S$ is in $\phi(R)$ then $R$ has an identity and $\phi(1_R)=1_S$.
Our OP palio's remarks are essentially correct.
My approach to this issue is very similar, to wit:
The conclusion that
$\phi(1_R) = 1_S \tag 0$
always holds true when $\phi$ is surjective; for let
$\phi:R \to S \tag 1$
be a homomorphism 'twixt the (not necessarily commutative) rings $R$ and $S$ such that
$\text{Range}(\phi) = S; \tag 2$
then for any
$s \in S \tag 3$
there is some
$r \in R \tag 4$
with
$\phi(r) = s; \tag 5$
since
$r1_R = 1_R r = r, \tag 6$
we have
$s = \phi(r) = \phi(r1_R) = \phi(r)(1_R) = s\phi(1_R), \tag 7$
and
$s = \phi(r) = \phi(1_Rr) = \phi(1_R)\phi(r) = \phi(1_R)s; \tag 8$
since (7)-(8) hold for any $s \in S$, we see by definiton that
$\phi(1_R) = 1_S, \tag 9$
that is, $\phi(1_R)$ is the multiplicative identity $1_S$ of $S$; note that we have in fact proved the existence of $1_S$ in this argument.
Of course, when $S$ has no zero divisors (i.e. is an integral domain in the event that it is commutative), then as was done by our OP palio we may write
$1_R = 1_R^2 \Longrightarrow \phi(1_R) = (\phi(1_R))^2 \Longrightarrow \phi(1_R) - (\phi(1_R))^2 = 0$ $\Longrightarrow \phi(1_R)(1_S - \phi(1_R)) = 0; \tag{9.1}$
we note that unless $\phi$ is the trivial homomorphism we have
$\phi(1_R) \ne 0 \tag{9.2}$
lest
$\forall r \in R, \; \phi(r) = \phi(r1_R)$ $= \phi(r) \phi(1_R) = \phi(r) \cdot 0 = 0, \tag{9.3}$
contradicting the non-triviality of $\phi$; this fact, combined with (9.1) implies
$1_S - \phi(1_R) = 0, \tag{9.4}$
that is
$\phi(1_R) = 1_S. \tag{9.5}$
If
$\text{Range}(\phi) \ne S, \tag{10}$
then $\phi(1_R)$ may not be the unit of $S$; a counterexample is provided by the homomorphism
$\phi:\Bbb Z \to \Bbb Z \oplus \Bbb Z \tag{11}$
defined by
$\phi(r) = (r, 0), \; \forall r \in \Bbb Z; \tag{12}$
then
$\phi(1) = (1, 0), \tag{13}$
but the multiplicative identity of $\Bbb Z \oplus \Bbb Z$ is $(1, 1)$.
Here we of course assume the operations in $\Bbb Z \oplus \Bbb Z$ act component-wise, that is
$(a, b) + (c, d) = (a + c, b + d), \tag{14}$
and
$(a, b) \cdot (c, d) = (ac, bd). \tag{15}$