Any solution based on sed (or anything else that doesn't do proper XML parsing) will be wrong in a proportion of edge cases. For example, the solution from @Pitel:
(a) replaces the content of things that look like name attributes even if they are in comments or text rather than in a start tag
(b) also changes the content of an attribute named
(c) fails to spot the attribute if it has whitespace around the equals sign.
So it might be adequate for one-off ad-hoc use, but don't put it into a production workflow. If you need something of production quality, use an XSLT transformation. It's not difficult:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:attribute name="name" select="translate(., '-', '_')"/>