By “second last layer” do you mean the second block in layer4?
If so, you could use the following code:
model = models.resnet18(pretrained=False)
model.layer4[1].relu = nn.LeakyReLU(inplace=True)  # your custom function here

Let me know, if you meant another layer.