You could use getattr to get the submodules using their names.
Here is a small example:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.fc1 = nn.Linear(1, 1)
        
    def forward(self, x):
        x = self.fc1(x)
        return x

model = MyModel()

keys = []
for name, value in model.named_parameters():
    keys.append(name)

with torch.no_grad():
    getattr(model, keys[0].split('.')[0]).weight.fill_(0.)  # split key to only get 'fc1'