Let $\mathfrak{A} = \langle A, \mathcal{F}^\mathfrak{A} \rangle$ and $\mathfrak{B} = \langle B, \mathcal{F}^\mathfrak{B} \rangle$ be algebras of the same type $\mathcal{F} \to \omega$, and let $\varphi \colon \mathfrak{A} \to \mathfrak{B}$ be a homomorphism. If $X \subseteq A$, denote by $\langle X \rangle_\mathfrak{A}$ the subuniverse (i.e. possibly empty subset of $A$ closed under the operations in $\mathcal{F}^\mathfrak{A}$) of $\mathfrak{A}$ generated by $X$. It is then easy to show that
$$ \varphi( \langle X \rangle_\mathfrak{A} ) = \langle \varphi(X) \rangle_\mathfrak{B}. $$
However, I have neither been able to prove nor disprove the analogous claim that
$$ \varphi^{-1}( \langle Y \rangle_\mathfrak{B} ) = \langle \varphi^{-1}(Y) \rangle_\mathfrak{A} $$
for $Y \subseteq B$. This is only possible in general if $Y$ lies in the image of $\varphi$, and it is obvious if $\varphi$ is also injective. But does it hold for all algebras, and if not, are there varieties for which it does hold?
The 'analogous claim' fails for groups whenever $Y=\emptyset$ and $\varphi$ is not injective. However, the claim is true for groups whenever $\emptyset\neq Y\subseteq \textrm{im}(\varphi)$.
The claim fails for lattices even in cases where $\emptyset\neq Y\subseteq \textrm{im}(\varphi)$. For example, let $\mathfrak B$ be the $4$-element lattice with universe $\{0,a,b,1\}$ defined so that $a\wedge b=0, a\vee b=1$. Let $\mathfrak A$ be the $5$-element lattice obtained from $\mathfrak B$ by adding a new top element $1'$. (So, in $\mathfrak A$ we have $0<a<1<1'$, $0<b<1<1'$, and $a$ and $b$ are incomparable.) Let $\varphi\colon \mathfrak A\to \mathfrak B$ be the map $\varphi(x)=x$ for $x\in \{0,a,b,1\}$ and $\varphi(1')=1$. Let $Y=\{a,b\}\subseteq B=\textrm{im}(\varphi)$. In this example, $\varphi^{-1}(\langle Y\rangle_{\mathfrak B})=\{0,a,b,1,1'\}$, while $\langle \varphi^{-1}(Y)\rangle_{\mathfrak A} = \{0,a,b,1\}$.
are there varieties for which it does hold?
As noted above, the question is sensitive to whether or not $Y=\emptyset$. In the following discussion, I assume that $\emptyset\neq Y\subseteq \textrm{im}(\varphi)$.
David Geiger announced some results in 1974 on what he called 'coherent' algebras and varieties. (See page A-436 of the link.) For Geiger, an algebra $\mathfrak C$ is coherent if whenever $\theta$ is a congruence on $\mathfrak C$ and $D$ is a subuniverse of $\mathfrak C$ containing a $\theta$-class, then $D$ is a union of $\theta$-classes. A variety $\mathcal V$ is called coherent if all of its members are. Geiger characterized coherent varieties as those varieties having a finite sequence of terms $F_1(x,y,z),\ldots, F_n(x,y,z)$, and $H(x,y_1,\ldots,y_n)$ such that $${\mathcal V}\models F_i(x,x,y)\approx y\;\textrm{for all $i$}$$ and $${\mathcal V}\models H(x,F_1(x,y,z),\ldots,F_n(x,y,z))\approx y.$$
Any variety whose members have underlying group structure is coherent. It is easy to show this by verifying the definition of coherence, or by referring to Geiger's result (take $F_1(x,y,z)=xy^{-1}z$, $F_2(x,y,z)=z$, and $H(x,y_1,y_2) = y_2y_1^{-1}x$).
I claim that the 'analogous claim' of the problem statement holds in any coherent variety in those situations where $\emptyset\neq Y\subseteq \textrm{im}(\varphi)$.
Reasoning. Applying $\varphi$ to $\langle \varphi^{-1}(Y)\rangle_{\mathfrak A}$ yields $\varphi(\langle \varphi^{-1}(Y)\rangle_{\mathfrak A}) = \langle \varphi\varphi^{-1}(Y)\rangle_{\mathfrak B} = \langle Y\rangle_{\mathfrak B}$, which implies that $\langle \varphi^{-1}(Y)\rangle_{\mathfrak A}\subseteq \varphi^{-1}(\langle Y\rangle_{\mathfrak B})$. This inclusion holds for any $\varphi\colon \mathfrak A\to \mathfrak B$ and any $Y$.
Now we argue that if $\emptyset\neq Y\subseteq \textrm{im}(\varphi)$ and our algebras come from a coherent variety, then the inclusion of the last paragraph is equality. Let $\theta=\ker(\varphi)$ and choose $y_0\in Y$. The subuniverse $\langle \varphi^{-1}(Y)\rangle_{\mathfrak A}$ contains $\varphi^{-1}(y_0)$, which is a $\theta$-class. By coherence, $\langle \varphi^{-1}(Y)\rangle_{\mathfrak A}$ is a union of $\theta$-classes. This implies that $\langle \varphi^{-1}(Y)\rangle_{\mathfrak A} = \varphi^{-1}\varphi(\langle \varphi^{-1}(Y)\rangle_{\mathfrak A}) = \varphi^{-1}(\langle \varphi\varphi^{-1}(Y)\rangle_{\mathfrak A}) = \varphi^{-1}(\langle Y\rangle_{\mathfrak B})$, as desired. \\\