The idea here is to superimpose a slightly raised | to the Z.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\NewDocumentCommand{\Zb}{}{{\mathpalette\Zb@\relax}}
\newcommand{\Zb@}[2]{%
\begingroup
\sbox\z@{\raisebox{0.125\height}{$\m@th#1|$}}% the bar to be used twice
\vphantom{\copy\z@}% this is to correctly set the bounding box
\ooalign{%
$\m@th#1 Z$\cr % the Z
\hidewidth\box\z@\hidewidth\cr % the bar
}%
\endgroup
}
\makeatother
\begin{document}
$\Zb$ $X_{\Zb}$
\end{document}

If you replace $\m@th#1 Z$\cr with
$\m@th#1 \mathsf{Z}$\cr
you get

A different implementation where the bar is set to a length that depends on the symbol.
This works well for symbols that are supposed to sit on the baseline (see the last example). An optional argument is available in order to set the type of the constructed symbol.
\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e}
\makeatletter
% to have the bar as wide as fraction lines
\newcommand{\getfontdimen}[3]{% https://tex.stackexchange.com/a/572774/4427
\fontdimen#1
\ifx#2\displaystyle\textfont\else
\ifx#2\textstyle\textfont\else
\ifx#2\scriptstyle\scriptfont\else
\scriptscriptfont\fi\fi\fi #3%
}
% the main command
\NewDocumentCommand{\barred}{O{}m}{#1{\mathpalette\barred@{#2}}}
% the internal command
\newcommand{\barred@}[2]{%
\begingroup
\sbox\z@{$\m@th#1#2$}% the symbol we want the bar over
% the bar, 0.3ex longer than the total height of the symbol
\setlength{\dimen@}{\dimeval{\ht\z@+\dp\z@+0.4\getfontdimen{5}{#1}{2}}}
\sbox\tw@{%
\raisebox{\dimeval{-\dp\[email protected]\getfontdimen{5}{#1}{2}}}{%
\begin{picture}(0,\dimen@)
\roundcap
\linethickness{1\getfontdimen{8}{#1}{3}}
\Line(0,0)(0,\dimen@)
\end{picture}%
}%
}%
\vphantom{\copy\tw@}% this is to correctly set the bounding box
\ooalign{%
\box\z@\cr % the symbol
\hidewidth\box\tw@\hidewidth\cr % the bar
}%
\endgroup
}
\makeatother
\newcommand{\Zb}{\barred{Z}}
\newcommand{\zb}{\barred{\mathsf{z}}}
\begin{document}
$\Zb$ $X_{\Zb}$
$\zb$ $X_{\zb}$
$\barred{g}$ $X_{\barred{g}}$
$a\barred[\mathrel]{<}b$
$a\barred[\mathbin]{\circ}b$ (not good)
\end{document}
