@oxido8310 – it's not *exactly* what you want, but maybe it's "good enough" for your purpose:
There is a startup script by Gerald Singelmann, that remembers the specific layer a specific object on a spread resides and makes it available before and after grouping.
That means, if objects are grouped, they will reside on a specific layer (you do not want that, I think), but if un-grouped they will be back to their former layers.
His blog post is in German at:
It is working with a German UI.
Don't know, if the latest versions of InDesign are supported.
Just test it out…
I think this is exactly what I need, I will test it out. Thnx!