I am trying to update a list of entities depending on labels.
I have created a label “Apple HomeKit” and generated the following code in the template editor:
As desired, this gives me a list of all entities that have the label “Apple HomeKit”.
I would now like to use this generated (dynamic) list in the “include_entities:” section in the .config file so that I only have to reload the integration to see these entities in HomeKit.
No you can not do that. The option does not support templates. The closest you can get is the include_entity_globs option that supports wildcards in the entity_ids.
Even if templates had been possible to use here (which sadly it is not as already mentioned), you cannot use a template like that. The correct way would simply have been to return the list as-is, since Jinja lists are automatically converted to YAML lists:
Someone did make a Jinja preprocessor for configuration.yaml but sadly that could only do limited templates (or possibly it was only plain Jinja without any of the HASS additions at all).