PostgreSQL - Cannot UPDATE pg_database
You can't update pg_database to change a database (you shouldn't be updating system tables at all, although you can do it for some of them). 

Use ALTER DATABASE instead:

alter database my_template_1
  with is_template true
       allow_connections false;