Although I really like the setup, I could not get your script to work. Using Home Assistant's group helper what you create as a group is slightly different from a group like you created.
Using the following change it now works. Less elegant than via a group but I could not get that to work and this does the trick:
action:
- service: script.light_duration
data:
light: >-
light.{{["mini_dimmer","philips_lwa004_huelight","philips_lwa004_huelight_2","plug_10_werkkamer_lamp_switch"]|random}}
duration: 00:{{ '{:02}'.format(range(5,30) | random | int) }}:00