Group subplot scatter legends

I have a multiplot (subplots) plot, with one or more scatter plots on each subplot axis.

Is there a way to group these scatters into a single entry in the global legend?

Using a scattergroup doesn’t work, they’re toggled together but I need one one entry per group.

My temporary workaround is to keep a global state and set the showlegend: true only to the first trace (of the same legendgroup) and to false` for traces afterwards.

Also, is there a way to style the legendgroups so they look like regular legend entries? It is… without additional margin between each legend group.