Mqtt and templates

Hello,
Can i do this for mqtt name:

 name: "Nivels {{ states.sensor.choosen_direction.state |replace ("_", " ") |capitalize }}"

i need to have the name as template that changes and also the state_topic that corresponds
also is it possible to save this data as a dynamic sensor o dynamic matrix or victor
Thanks in advanced

I have never seen templates being used in the name field before, so I don’t think it is possible.

Hello, what about this ?? is it possible ?
it is supposed to run the script 4 times everytime with the selected value

  action: 
    - service_template: >
        {%- for SelectedX in ("value_1", "value_2", "value_3", "value_4") -%}
          service: script.turn_on
            entity_id: script.control_data
            variables: 
              Selected: "{{SelectedX}}"
        {% endfor %}

This is way beyond my jinja skills. Anything this complex I do in Python using appdaemon.

The syntax is correct but Ha gives invalid template service when executed!!!

how about this ??
needs a python code??

    - service_template: >
        {%- for SelectedX in states.input_select.chooser.attributes.options -%}
          - service: script.turn_on
              entity_id: script.control_script
              variables: 
                Selected: "{{SelectedX}}"
          - delay: 00:00:{{ states.sensor.tiempo_movemiento.state }}    
          - delay: 00:00:12
          - service: script.turn_off
              entity_id: script.control_script
        {% endfor %}

what is the equivalent python script to this?