It is in principle possible to designate a municipality as the beneficiary of life insurance provided that it fulfills certain obligations (we speak of a beneficiary clause with charges or conditions). The insurer may nevertheless refuse a clause like the one you are considering, because he will have no way of verifying that the municipality complies with the charges imposed once the capital has been paid.
Read also: Life insurance: can I set conditions for the beneficiary of my contract?
You can consider doing otherwise, by bequeathing the capital of your life insurance to these two municipalities by will. (or to associations), subject to maintenance of the concessions (and possibly their renewal if they are not perpetual), while designating the person of your choice who will be responsible for ensuring compliance with the charges of this legacy. Your notary can advise you on the drafting of your will in this regard.