This is a hardware issue, in that the OS reads the battery and in this case the motherboard does not perform any calculation.
Laptop LiIon battery packs are usually equipped with a charge indicator chip that also tracks battery health, lifetime, and error conditions; the laptop from the outside may at best sense an impossibility to charge, or a battery full, but little more. Voltage gauging is unreliable at best.
Completely discharging the battery (with "completely" meaning "to about 5% of its nominal capacity" for LiIon units) ought to recalibrate the internal chip, and in turn fix the OS "problem" when the chip resumes reporting correct values.
But it might well be the case that the battery chip has theoretically correct data, and it is the battery internals that are defective. Even if it's just one element overcharging and halting the last part of the LiIon charging cycle, it might not be possible to fix this in terms of "battery pack" - you might need to discharge the single defective element, which usually can not be done with composite batteries: you would need to pry open the battery - voiding any warranty - and connecting each 3.7V element, almost certainly a 18650 LiIon, to an appropriate dummy load until it reaches the lower voltage bound for a remaining capacity of 5%. And if you get the bound wrong, you might damage the element, which is why there are specialized circuits to do this.
There's then the question of why one element over- or under- charged; if it's a inherent construction flaw of the battery (e.g. a defective weld), the problem will soon reappear.
The best procedure one can follow with no significant risks is the standard "run discharge" you can find detailed here.
Then there is the dangerous way - disassemble the pack, test and charge cycle each individual unit, replace any faulty one, reassemble; which, given the tightness inside a battery pack, is not at all easy. And I could change no more than three seconds of a video such as this to add slight defects, and the battery would turn into an appreciable incendiary bomb (which explains why laptops get checked at airports). Compare that risk to the street price of a less funny, but way safer brand new battery.