I'm not sure if I understand your question correctly. I'll try to answer, but you ay want to clarify what you're asking.
I'll review portfolio optimization and constraints.
Typically, you have a universe of assets to possibly invest in, and a matrix of pairwise covariances between the assets (variances on the diagonal), and an optimizer such as HiGHS or cvxopt.
When Markowitz got an economics Nobel Prize in 1990, lots of quant shops reacted to the media buzz by offering pretty much the same thing:
1 pick a universe of a few hundred stocks using some criteria, hoping that this universe would outperform the market
2 use a quadratic optimizer to find a minimum-covariance portfolio. For the vast majority, the objective function being minimized was just the portfolio covariance.
Some people included some kind on "alpha" in the objective function, such as a "buy" or "sell" from their favorite research, signifying that some assets are more or less desirable; included some kind of transaction cost of moving from the current portfolio weights to the new optimal weights; and tweaked the covariance matrix in some ways supposed to produce a better optimal portfolio.
Without constraints, the optimization would invest all the money in a small number of low-variance assets. To avoid this, and to force more diversification, you need linear constraints. For example, for each asset, you'll probably need a constraint forcing the weight of this asset to be no more than 1% (or 5%, or whatever you think is OK in one asset). For a long-only portfolio, you need the weight of each asset to be >=0. You might also have an upper bound on some industrial sectors, or on some screens used to construct the universe.
As KaiSqDist mentioned, having all the weights add up to 100% is one obvious equality constraint. I can think of a few more practical use cases for equality constraints. For example, suppose that two corporations in your portfolio have merged, resulting in a combined weight exceeding your single-name upper bound. Or suppose that a corporation got taken private, requiring you to tender the stock and to receive cash that you need to put to work. In order to reduce transaction costs, you may want to run an optimization where the assets that you won't want to change for now would have an equality constraint forcing the weight to remain the same, and letting the optimizer find substitutions for the deleted assets that would minimize the objective function.
If you have some ESG score for each asset, I see several ways to use it, for example:
1 you can identify all the assets with the ESG score below a certain thresholds, or are into fossil fuels, or otherwise undesirable, and have an equality constraint forcing them all to 0. But the same result be accomplished more efficiently by not having the excluded assets in the universe and the covariance matrix.
2 you can include the ESG score in your objective function, like the alpha mentioned above.
3 you can have an inequality constraint requiring the weighted ESG score of your portfolio to be above some minimal threshold.
However I can't think of a realistic use case with ESG scores in an equality constraint. Suppose you have ESG scores between 0 and $n$, and you force the optimized portfolio ESG score to be exactly $k<n$, rather than $\gt k$. In other words, you instruct your optimizer to reject a portfolio that might have both better objective function (lower covariance) and better ESG score. Why would anyone want that?