Ah! Thank you! I got it now :)
Using d3.js I had to set svg.attr("xmlns:inkscape", "http://www.inkscape.org/namespaces/inkscape")
and then
let g = svg.append("g")
g.node().setAttributeNS("inkscape","inkscape:groupmode", "layer")
g.node().setAttributeNS("inkscape","inkscape:label", "1-Yellow")
and now it works like a charm ^_^