I am currently working on a flow which analyses data from a machine and shows the result on a dashboard.
To make this project scalable for multiple machines my idea is to put the flow in a subflow which can be easily reused. I would like to avoid copying the code and assign the widgets by hand ever time.
The problem is that I don't see any possibility to assign the UI widgets to different Tabs and Groups dynamically. The Best case would be that I can define the Group/Tab by a msg.payload.tab or something.
No, you are correct, it is not currently possible,
When you get to this level of sophistication you may want to look at he node-red-contrib-uibuilder node that allows you much greater flexibility of dashboard as you can bring whatever framework you like to work with it, albeit at the cost that you have to build it yourself.
I build a pretty large dashboard with all the Tabs / Groups / Widgets in it. Then in subflows I hide / show & enable / disable the tabs to give the appearance of a dynamic dashboard. Use the ui_control node to do that. Works really well. Multiple copies of a subflow of course 'collide' as they both want to talk to the same set of widgets. So it depends on how much 'flexibility' you really need.
If you know in advance what you could possibly display (and the sequence of things in the Tabs / left nav menu is not CRUCIAL) then this may work for you.