Home Assistant process YAML first then Jinja2 second therefore you cannot use Jinja templating to generate YAML within configuration.yaml. More information here.
What you can do is use Jinja2 templating in the Template Editor to generate YAML, then copy the generated YAML into configuration.yaml (see example). It’s up to you to decide if that’s faster than creating a single entity’s configuration and then copy-pasting it to create other entity configurations.
Unless of course the bash script that generates YAML contains an error …
Regardless of the chosen programming language (bash script, Jinja2, python, etc), there are pros and cons to creating YAML- generating code. The time needed to compose and test the code may be longer than simply copy-pasting a few blocks of YAML.
For future projects, you may wish to familiarize yourself with the concept of YAML Anchors and Aliases. I posted an example here: