How to weight examples to minimize some feature/output? I'm working on a Regression problem consisting on predict some continuous variable $Y$, as usual. The thing here is that there are two kinds of data examples: some that have a value of $Y$ a little larger than they should, and some that have it exactly right, so in the optimization task of the algorithm (min. the loss function) the magnitude of $Y$ should be considered, as not only is important to get as close to $Y$ as possible, but as low $Y$ is, the better.
For example, in a regular regression problem, in the case below the grey line would be our best possible model because the error is minimum for it, but for this case not only the error is important, the magnitude of the output matters too, so imagine that A point has a quite lower $Y$ than B, it will provoke the model to shift towards it, as seen in the red line, because it minimizes the error and the magnitude.

My question here is how this could be achieved? Is there any technique to weight the examples before learn to predict them, so receive more importance those with lower $Y$? Is it possible to add this magnitude to the loss function in order to try to minimize it too?
I don't know exactly how to think about this, so whatever help you could provide would be quite useful. Thanks!

Pretty cool question!
first I have to say that adding your pre-existing knowledge will change the results. So proceed with caution.
I would formulate the problem in one of the following ways:
Method 1 :
Perform regression as usual.
Then calculate  and add it to each sample weight.  now becomes a hyperparameter you need to also find.
now perform the regression with the updated weights.
as you've lowered the weight of the samples above the predicted curve and increased the weight of the samples below the predicted curve, the curve will be pulled towards the points below the curve.
Method 2 :
This requires defining your own optimization goal. regular OLS minimizes the objective 
add the term   to the standard objective and minimize it using your favorite optimization method. this gives you a new optimization objective:

This again lowers the loss of points above the predicted curve and increases the loss of points below the curve, moving the optimal solution closer to the lower points.
but you have to be careful as selecting a large value of  will move the curve below all the points.
