Hi @Charlie Cobre ,
Welcome to Microsoft Q&A! Apologies for the delayed response.
With Azure Policy itself, there is no way to restrict the creation of a VM with same name in a Resource Group. However, the VM name must be unique in a single Resource Group, i.e., the names of resources must be unique in a resource group. If you are looking for a solution to avoid same name VMs at a Resource Group level, there is no need to configure anything extra as such VM creation request would fail anyway.
Regarding Terraform question, I would request you to post the query to Terraform community for help.
Please let me know if you have any questions.
---
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.