OK, here's the completely untested SQL. Do not think of running this in production before testing it on a testing server and making complete DB backup. Replace AAA with item_id of your template item and BBB with the parent community - the template will be applied to all its collections.

UPDATE collection SET template_item_id = AAA
FROM community2collection
WHERE collection.collection_id = community2collection.collection_id
AND community2collection.community_id = BBB;


Compulsory reading: DSpace Mailing List Etiquette