You can take the weights of the first layer with model.layer1.parameters(), and apply your penalty only to those weights.
To penalize the gradient of a layer, have a look at the Higher Order gradients in https://github.com/pytorch/pytorch/releases/tag/v0.2.0 26