Caret model with custom cost function

I want to train an Elastic Net classifier with a case-weighted error function. The function needs to accept an extra argument weights that allows different observations to carry different weights when calculating performance error. Is this possible to do in Caret?

# Weighted RMSE function with weights argument.
weighted_rmse <- function(prediction, target, weights) {
  sum(abs(prediction - target)) * weights
}

# Example data.
trainX <- iris[1:100, 1:4]
trainOutcome <- as.numeric(iris$Species[1:100])

fit <- train(
  x = trainX, y = trainOutcome,
  method = "glmnet",
  trControl = trainControl(
    method = "loocv",
    selectionFunction = "oneSE",
    summaryFunction = twoClassSummary # <- replace with something like weighted_rsme()
  )
)