How to make loop for Azure locks using terraform

Hi, I just want to have loop structure for locking system of my azure resource groups. Consider I have number of resource groups in my Azure environment. I’m using terraform to manage entire Azure resources. I have separate repo and pipeline for locks so that it won’t mess with other infrastructure.

Requirement: I want to put read-only to specific resource groups and all for delete locks. I want to have single resource block which will run based on the conditions that we specify. For example, I used boolean like below,

resource "azurerm_management_lock" "locks" {
count     = var.resourcegroupbool ? 1 : 0  #here also I want to use variables, currently shown is bool and need to have group of boolean        
name      = var.env == "dev" ? "Read-lock" : "Delete-lock"  
scope     = #here I want to use variables based on resource group but I didn't get it
lock_type = var.env == "dev" ? "ReadOnly" : "CanNotDelete" }

I need to use only above one resource block for both readonly and delete locks for all resource groups. In addition, I used count here to specify whether lock needed to be deployed or removed if exists and this is done using boolean variable. You can use modules, locals, count, for each but I would be needing all in a single resource block. I tried multiple ways but no hit. I have object of boolean in my resourcegroupbool variable but not sure how I can integrate for all? Could you please anyone guide here?

Tried with modules, object of boolean variables but no hit.