An unaided RPi is unable to
measure (to the sort of accuracy I imagine you seek) anything as its inputs are essentially 'yes/no' types. You need an Analogue to Digital Converter. See eg
https://learn.adafruit.com/raspberry-pi ... rs/mcp3008 though there are many, many other possibilities. Note that if operating that chip from 3.3 volts (to make its interface compatible with a RPi) you might need to scale down the battery voltage (with a resistive divider) before applying it to the ADC input.
However I question your motive. There is no 'naked' battery that is suitable for directly powering a RPi. You always need a regulator or converter between the battery and the RPi. (USB power banks already incorporate that.) So the input to the micro-USB socket on a RPi should be remarkably constant and almost useless as an indication of remaining run time. Only if you have access to the actual battery terminals can you measure its voltage.