Li-ion battery calibration technique
There are multiple techniques with various tradeoffs between them.  If you search the literature for "battery fuel gauge" you should come up with a number of techniques.

Note that you can actually estimate SOC from voltage, provided the load is zero and the battery has been allowed to rest in this state for a while (hours).  This relationship is not linear though, so you need to characterize the particular battery you're using and use some sort of a lookup table.  Your voltage measurements also need fairly high precision and accuracy.  

A more reliable method is coulomb counting, during both the charge and discharge cycles.  This will provide a very accurate assessment of the amount of stored energy, and you only need to subtract out any self-discharge (which should be very small).  However, measuring the current is a bit more costly, in terms of size, power loss, and $.  And due to the self-discharge rate being variable and unknown, this technique needs periodic calibration or it will start to drift off from the true reading.  This is typically done by resetting the high and low points after a full charge or full discharge respectively.

You can also combine these techniques (and possibly others) for even more accuracy and to mitigate drift effects.  

This is how one manufacturer of battery fuel gauge ICs implements it:
https://www.maximintegrated.com/en/design/partners-and-technology/design-technology/modelgauge-battery-fuel-gauge-technology.html