recall that, in general, you have the following elements:
A universe of possible stocks. There are tens of thousands of possible investments out there, so you apply screens to limit your universe to a feasible size, like a few hundred. For example, you could rank lots of stocks by some fundamental value or growth criteria, and include the top n from each screen in the universe.
a covariance matrix. The classic Markowitz approach is to collect several years worth of time series of total returns for each stock, and calculate historical volatilities and correlations. But some people tweak the matrix seeking to better predict future correlations; or to make the matrix much smaller by using factors; or to allow stocks without history to still be in the universe by using some guesses of future volatilities&correlations instead of hisorical volatilities&correlations; et al.
lots of linear constraints, without which the optimizer might decide to have few large positions in the least volatility stocks. For example, if you want the portfolio long-only, you put a minumum of 0 on each stock. If you don't want than n% in a single stock, you put this constraint on each stock. But you may also want to limit what percentage of the portfolio is picked by the same screen, or is in the same country or industry.
the objective function that you ask your quadratic optimizer to minimize. The classic Markowitz approach is to minimize the covrage of the portfolio, and to assume that the screens generate all the alpha you want. But most people add other competing considerations in the objective function, like their own idea of alpha; some penalty for the transaction cost of rebalancing the existing portfolio (the difference between the old weight and the new weight).
If you have some kind of ESG data (boolean flags or some kind of scores) for the stocks in your universe, then they can fit in several parts of this framework. If some companies are flagged as being so evil that you never want to trade them (e.g. use child slave labor to genetically modify penguins and to drill for petroleum in the Antarctic), not even short, then you can exclude them early on as part of your screens, and not even incllude them in the covariance matrix. You can also use ESG in linear constraints, e.g. the maxium carbon emission of the prtfolio must be below some threshhold, and no less than some percentage of the portfolio must have unionized workforce, and no more than some percentage must have all-male boards of directors.
But including the ESG as a kind of alpha in the objective function that already has the covariance and transaction cost penalty and possibly other alpha is tricky. You don't want some of the objective function's components to be dominated by other components and ignored.
You should also look at Scientific Beta's papers.