You can’t generate complex data structures from a template like that - you can only generate a value for a key. I believe you could do something like this with a YAML loop: Script Syntax - Home Assistant
Only because you have misunderstood a template’s purpose. It is used to compute an option’s value. You’re trying to use it to generate YAML statements (in other words to generate additional options). That has never been a valid use-case in Home Assistant (and the documentation contains no description or examples of it).
There is no service call to create an input_boolean entity. However, if you have already created all of the required input_booleans, it is possible to loop through them and assign values. Let me know if this is the case and I can help you compose the script.