It doesn’t measure the weight; how could this be the case?
It measures the distance travelled, and the amount of fuel being used (I think it also measures the approximate amount left in the tank, but there must be an instantaneous measurement of fuel flow because when the display is in momentary fuel consumption mode, it reacts quite responsively to changes (it isn’t just fudging it from the engine revs either, as, for example, maintaining revs by depressing the accelerator as you start to ascend a hill registers a reduction in mpg).
These sort of threads seem to go this way every time (remember the one where the laws of physics wouldn’t allow a cat to jump more than three feet in the air, and the one where attaching helium balloons to cancel most of your body weight wouldn’t allow you to jump any higher?
I think you’ve probably oversimplified the problem, or rather ignored some of the variables; chiefly wind resistance, rolling friction and the efficiency curve of the engine; as I said, when driving the car unladen, it is sometimes necessary, on the way down a gentle slope, to apply engine power in order to keep the car from decelerating to an unacceptably low speed, even coasting in neutral, whereas descending the same slope when fully loaded, the car will accelerate down the hill in neutral.
Now of course it takes more energy to get the car up to the top of the slope to begin with, but this is an entirely unrelated factor.
In a frictionless, airless environment, starting from the top of a hill, an unpowered car would accelerate downhill and would reach a point equally high on the way up at the other side, regardless of load.
Add in friction and air resistance though, and the same unpowered vehicle would accelerate down the hill (more slowly due to the resistance) and would roll back up the other side to a point considerably lower than the starting point, BUT a heavier car will go further than a lighter one.
There are a range of factors at play here, each with its own curve; what I believe is the case is that when all the graphs are combined, the plot would be a curve with a dip in the middle, representing the weight at which maximum fuel efficiency is achieved and that the normal unladen weight of the vehicle marks a point that isn’t at the lowest part of the dip.