In universal algebra, I am trying to find a counterexample using groups for the converse of the following:
If $\mathcal{A},\mathcal{B}$ are algebras, and $\phi:\mathcal{A}\to \mathcal{B}$ is a surjective homomorphism and the identity $\mathbf{s}=\mathbf{t}$ holds in $\mathcal{A}$, then it also holds in $\mathcal{B}$.
I was thinking the trivial homomorphism could possibly be a counterexample: $G$ any non-abelian group, $H$ any abelian group, $\phi: G \to H$ defined by $\phi(g)=1$ and the identity can be commutativity. If $H$ is not trivial, then $\phi$ is not surjective.
Is my counterexample too complicated or wrong? Any advice on how to find a simple one?
For any kind of algebra (regardless of the operations it has) the converse of that result is indeed false.
Just consider that if $\mathbf A$ is an algebra, then $\theta = A^2$ is a congruence on $\mathbf A$, and the quotient $\mathbf A/\theta$ is a one-element algebra.
Now, one-element algebras satisfy the equation $x=y$, and they're the only ones that do.
So if $\mathbf A$ is a non-trivial algebra (if it has more than one element), you can consider $\mathbf B = \mathbf A/\theta$, and the only possible map $\phi:\mathbf A \to \mathbf B$ is a surjective homomorphism, showing that the converse of the result is false.
Notice that it is necessary that $\mathbf A$ is non-trivial, since trivial algebras (trivially) satisfy any equation whatever.
Now you can just as well replace $x=y$ by any equation that you know that the non-trivial algebra $\mathbf A$ doesn't satisfy (because $\mathbf A/\theta$ always does).
In particular, if $\mathbf A$ is a non-commutative group, you can consider the identity $xy=yx$, as you did.