Я помещаю цвета в массив.Я устанавливаю счетчик.Счетчик n ++ каждый раз при нажатии.Я устанавливаю цветовой класс для группы
n %= colors.length;
btn1.setAttribute("class", colors[n])
Пожалуйста, прочитайте комментарии в моем коде
//the array of the colors
let colors = ["tomato","gold","skyblue"];
//the attay of the polygons
let polygons = Array.from(svg.querySelectorAll("#btn1 polygon"));
let n = 0;
svg.addEventListener("click",()=>{
//remove the fill attribute of the polygons
polygons.forEach(p =>p.removeAttribute("fill"))
//the color for the group fill
n %= colors.length;
//reset the class name for the btn1
btn1.setAttribute("class", colors[n])
n++
})
svg{border:1px solid;width:100px;overflow:visible}
polygon{stroke:black}
.tomato{fill:tomato}
.gold{fill:gold}
.skyblue{fill:skyblue}
<svg id="svg" viewBox="300 50 230 650" >
<g id="btn1" >
<polygon fill="#FF0013" points="366.699,131 410,56 453.301,131"/>
<polygon fill="#07FF00" points="323.699,656 367,581 410.301,656 "/>
<polygon fill="#0000FF" points="409.699,656 453,581 496.301,656 "/>
<polygon points="366.699,581 410,656 453.301,581"/>
</g>
</svg>