Many optimizers have a L2 penalty option: http://pytorch.org/docs/master/optim.html?highlight=torch%20optim#torch.optim.Adagrad 37 . This adds a constant times the weights to the gradient of the loss (you can check this behavior in the source code 12).
You could probably add a manually defined L1/L2 regularization by adding the relevant values to the output of a loss function.