To do it before the forward I would do the following:
class MyModel(nn.Module):
    def __init__(self):
        super(MyModel, self).__init__()
        self.cl1 = nn.Linear(5, 4)
        self.cl2 = nn.Linear(4, 2)

        # Move the original weights so that we can change it during the forward
        # but still have the original ones detected by .parameters() and the optimizer
        self.cl1.weight_orig = self.cl1.weight
        del self.cl1.weight
        
    def forward(self, x):
        # Recompute the weight attribute based on the original value
        self.cl1.weight = get_new_weight(self.cl1.weight_orig)

        # Do the regular forward
        x = self.cl1(x)
        x = F.relu(self.cl2(x))
        return x