How to pass a group value in inventory file to jinja2 template file in ansible

If you are absolutely certain that the group only contains a single value, you can use the first() filter on the variable to get the first element from the list:

swarm_hostname: "{{ groups['dockerSwarmManager'] | first }}"

If it is possible that there are multiple hosts you could also use join():

swarm_hostname: "{{ groups['dockerSwarmManager'] | join(',') }}"

This would create a comma separated list, which I assume would be acceptable from your example.

And of course, this also works directly in your JSON template:

"wellKnownUrl": "https://{{ groups['dockerSwarmManager'] | first }}/my-configuration",