For $n\in\mathbb{Z}$, let $[n]=\{x\in\mathbb{Z}:x\geq n\}$ and let $A$ be the set of all functions $[n]\to\{0,1\}$ which are eventually $0$, where $n$ can be any integer. Let $f:A\to A$ be the map that restricts a function $[n]\to\{0,1\}$ to $[n+1]$. Let $g:A\to A$ be given by $g(a)(x)=a(x+1)$ (so $g$ maps functions $[n]\to\{0,1\}$ to functions $[n-1]\to\{0,1\}$) and let $h:A\to A$ be given by $h(a)(x)=a(x)$ if $x\neq 0$ and $h(a)(0)=1-a(0)$ (so $h$ maps functions $[n]\to\{0,1\}$ to functions $[n]\to\{0,1\}$). Note that $g$ is a bijection, and that $g,g^{-1},$ and $h$ all commute with $f$.
Now let us consider $A$ as an algebra with respect to the unary operations $g,g^{-1}$, and $h$. Then $f:A\to A$ is a homomorphism which is surjective but not injective. I claim that the only nonempty subalgebra of $A$ is $A$ itself, and so $f:A\to A$ is a counterexample to your question.
To prove this, just observe that any element of $A$ can be taken to any other element by repeated application of $g,g^{-1}$, and $h$. We can first use $g$ or $g^{-1}$ to assume the two elements have the same domain, and then we can use $h$ conjugated by $g$ any number of times to modify the finitely many values on which the functions differ. So, any element of $A$ generates the whole algebra.
Here is another perspective on this example. You could instead consider $A$ as a $G$-set where $G$ is the group of permutations of $A$ generated by $g$ and $h$. This group can be identified with the lamplighter group in an obvious way, and then $A$ can be identified with the coset space $G/H$ where $H$ is the subgroup generated by the elements $g^nhg^{-n}$ for all $n>0$. The map $f$ then sends a coset $xH$ to $xg^{-1}H$. This is well-defined since $gHg^{-1}\subseteq H$ but not injective since $gHg^{-1}$ is a proper subset of $H$.
In the same way, then, you could let $G$ be any group with a subgroup $H$ and an element $g\in G$ such that $gHg^{-1}$ is strictly contained in $H$. Then taking $A$ to be the $G$-set $G/H$, the map $f:A\to A$ given by $f(xH)=xg^{-1}H$ is a surjective but not injective homomorphism, but $A$ has no nonempty proper subalgebras.