Where does iPhone store information about current battery percentage?
All of the battery and power usage information (including approximately how much power applications and certain system processes use over time) is stored in /var/mobile/Library/BatteryLife/CurrentPowerlog.PLSQL and /var/mobile/Library/BatteryLife/Archives/powerlog_*.PLSQL. This data is both used to aid in the calculation of battery percentage and to unmask power-hungry applications.

Apple's algorithm for battery percentage is based on a number of factors: the maximum capacity of the battery (known based on the battery that the iOS device was manufactured with), the remaining capacity of the battery (calculated based on Voltage), power usage over time (stored in CurrentPowerlog), and current power usage (calculated based on draw). This data is all put together to extrapolate an estimated remaining capacity which iOS displays as the battery percentage.

When the iOS device is in a different mode other than iOS (such as DFU Mode or Recovery Mode), it does not store or read any information from the CurrentPowerlog database; it uses the direct method of determining the capacity of its Lithium-Ion battery: simply the Voltage that the battery is currently outputting. Take a look at a Voltage over time chart for Li-Ion batteries, and you may wish to read more information about determining capacities for Li-Ion batteries.