Is it possible to mimic the output of
\section{\texorpdfstring{$x_1$}{x\_1}}
using \section{$x_1$} and \pdfstringdefDisableCommands{...} ? I've only seen this answer, which tries to do something similar, but it doesn't work (as they acknowledge). I'm not too concerned about warnings; I just want x_1 to appear in the bookmarks for the PDF, while not having \texorpdfstring{...}{...} for every instance of an underline.
MWE for the error generated by tikz when using @StevenB.Segletes's first solution:
\documentclass{article}
\usepackage{hyperref}
%\usepackage{tikz} % OK
\let\svus_
\catcode`_=\active
\gdef_{\texorpdfstring{\svus}{\string_}}
%%%
% pgfmathparser.code.tex
% ! Missing \endcsname inserted.
% <to be read again>
% \svus
% l.251 ...mnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
% \usepackage{tikz}
%%%
\begin{document}
\tableofcontents
\section{$x_1$}
Document math, $a^3_1$ should be no problem
\section{$y_1$}
Does This_work?
\end{document}


\section{\texorpdfstring{$x_1$}{x₁}}, but it wouldn't be trivial to automate this. – Ulrike Fischer Sep 14 '21 at 08:58