Grouping by multiple arrays is now natively supported since Xarray>=2024.09.0.
https://xarray.dev/blog/multiple-groupers#more-complex-time-grouping
import xarray as xr
ds = xr.tutorial.open_dataset("air_temperature")
ds.groupby(["time.year", "time.month"]).mean()
I think your real problem is solved by "resampling", for which we support complex season definitions now (Xarray >2025.04.0):
import xarray as xr
from xarray.groupers import SeasonResampler
ds = xr.tutorial.open_dataset("air_temperature")
ds.resample(time=SeasonResampler(["DJFM", "AMJ", "SON"])).mean()
https://docs.xarray.dev/en/latest/user-guide/time-series.html#handling-seasons