HI @Ananya Shrivastava,
Deny assignments in Azure cannot be created directly through the portal, CLI, or PowerShell. They are managed by Azure and can only be established when deploying resources through a Deployment Stack
But there is an alternate approach other than using Deployment Stack you have an azure blueprint that will do your job, before choosing this refer below screenshot and article
Blueprint further will be used by Deployment stacks you have to do a rework if you are going with blueprint
https://learn.microsoft.com/en-us/azure/governance/blueprints/concepts/resource-locking
https://learn.microsoft.com/en-us/azure/governance/blueprints/overview
Please provide your valuable comments
Please do not forget to "Accept the answer” and “upvote it” wherever the information provided helps you, this can be beneficial to other community members.it would be greatly appreciated and helpful to others.