Hi there,
Yes, you can define the portfolio in the template itself so that anytime it's used in a project, the portfolio is always filled in. In terms of who can then change that, that's based on the permissions on the template and the projects it's used in and the access levels of your users. For example if you have Contribute access on a project and the access level they have, like a Worker, they can log time, mark tasks complete, make updates, etc. but cannot edit the portfolio field of a project. So it just depends on your access levels and how the template sharing vs project sharing of your templates are set.
If this helped you, please mark correct to help others : )