'How to use a custom elastic net function with glmnet in R

I am doing binary classification with Elastic Net Logistic Regression in R. Now I want to customize the elastic net function to contain "Correlation Based Elastic Net Penalties". see the formula below. Is there a way to specify custom penalties like this in R using the glmnet or Caret package? Thanks in advance!

Regular Elastic Net' Custom Elastic Net



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source