I save a copy of \section and then redefine it so that resets the figure counter immediately prior to calling on the saved copy of \section.
To change the style of the typeset figure number, renew the definition of \thefigure, done here as \renewcommand\thefigure{\thesection--\arabic{figure}}, so that the first figure of each new section will have the number <section number>--1. (also works with appendices).
\documentclass{article}
\let\svsection\section
\def\section{\setcounter{figure}{0}\svsection}
\renewcommand\thefigure{\thesection--\arabic{figure}}
\begin{document}
\section{First}
\begin{figure}[ht]
\centering
\fbox{FIRST}
\caption{First}
\end{figure}
\section{Second}
\begin{figure}[ht]
\centering
\fbox{SECOND}
\caption{Second}
\end{figure}
\begin{appendix}
\section{Appendix}
\begin{figure}[ht]
\centering
\fbox{APPENDIX}
\caption{Appendix}
\end{figure}
\end{appendix}
\end{document}

nis the number of the associated section. – Mico Sep 22 '21 at 15:32