$\newcommand{\Y}{\mathcal{Y}}\newcommand{\ZZ}{\mathcal{Z}}$It appears that for all $u\in\Y$ and all $z\in\ZZ$ we have
\begin{equation*}
f(u)=z\iff u\in z \tag{1}
\end{equation*}
and
\begin{equation*}
f'(u)=\begin{cases}
z_1'&\text{ if }u\in z_1'=z_1\setminus\{\bar y\}, \\
z_2'&\text{ if }u\in z_2'\cup\{\bar y\}, \\
f(u)&\text{ if }u\notin z_1'\cup z_2'=z_1\cup z_2.
\end{cases}
\tag{2}
\end{equation*}
Then the identity
\begin{equation*}
P(X=x,Y=y|Z=z_1)=P(X=x,Y=y|Z'=z_1')\frac{P(Z=z_1)}{P(Z'=z_1')} \tag{3}
\end{equation*}
does not hold in general, even if $y\ne\bar y$. Indeed (assuming $P(Z=z_1)\ne0$ and $P(Z'=z_1')\ne0$), we can rewrite (3) as
\begin{equation*}
P(X=x,Y=y,Z=z_1)=P(X=x,Y=y,Z'=z_1')\frac{P(Z=z_1)^2}{P(Z'=z_1')^2}. \tag{5}
\end{equation*}
However,
\begin{equation*}
P(Z=z_1)=P(f(Y)=z_1)=P(Y\in z_1)=P(Y\in z_1'\cup\{\bar y\})
=P(Y\in z_1')+P(Y=\bar y)
\end{equation*}
and
\begin{equation*}
P(Z'=z_1')=P(f'(Y)=z_1')=P(Y\in z_1'),
\end{equation*}
so that
\begin{equation*}
\text{$P(Z'=z_1')=P(Z=z_1)$ iff $P(Y=\bar y)=0$. }\tag{6}
\end{equation*}
Also,
\begin{multline*}
P(X=x,Y=y,Z=z_1)=P(X=x,Y=y,f(y)=z_1) \\
=P(X=x,Y=y)1(f(y)=z_1)=P(X=x,Y=y)\,1(y\in z_1)
\end{multline*}
and
\begin{multline*}
P(X=x,Y=y,Z'=z_1')=P(X=x,Y=y,f'(y)=z_1') \\
=P(X=x,Y=y)\,1(f'(y)=z_1')=P(X=x,Y=y)\,1(y\in z_1'),
\end{multline*}
so that
\begin{equation*}
P(X=x,Y=y,Z=z_1)=P(X=x,Y=y,Z'=z_1') \tag{7}
\end{equation*}
if $y\ne\bar y$.
Thus, (5) does not hold for all $y\ne\bar y$ unless $P(Y=\bar y)=0$, and hence (3) does not hold for all $y\ne\bar y$ unless $P(Y=\bar y)=0$.
On the other hand, the identity
\begin{equation*}
P(X=x,Y=y|Z=z_1)=P(X=x,Y=y|Z'=z_1')\frac{P(Z'=z_1')}{P(Z=z_1)},
\end{equation*}
which is equivalent to (7) (which also was in question), will always hold for all $y\ne\bar y$.