How to use r2-score as a loss function in LightGBM?
$R^2$ is just a rescaling of mean squared error, the default loss function for LightGBM; so just run as usual.  (You could use another builtin loss (MAE or Huber loss?) instead in order to penalize outliers less.)