Import yaml multiple times and keep IDs unique


I am trying to integrate two solar installations into my homeassistant installation.
I have a yaml file, which defines the modbus of one solar installation, and everything works fine.

  - name: SungrowSHx
    type: tcp
    host: !secret sungrow_modbus_host_ip
    port: !secret sungrow_modbus_port
      - name: Sungrow device type code
        unique_id: sg_dev_code
        device_address: !secret sungrow_modbus_slave
        address: 4999
        input_type: input
        data_type: uint16
        scan_interval: 600

Now I want to import the same file for the second installation.

How can I template the yaml file in a way, to keep the unique ids unique?

 unique_id: sg_dev_code ->  unique_id: sg_dev_code_{tag}

Is there a way to assign a prefix to every id?

Cheers, Christopher