If you know the gravity and physical weight of the beer, then you can work out the quantity (volume) like this:
V = W / SG
V is the volume in liters
W is the weight of the beer in kilos
SG is the specific gravity, e.g. 1.040
For this to be accurate, you have to be weighing just beer - the trub and yeast should not be present.
US Gallon = 3785ml
Imperial Gallon = 4546ml
To convert to US gallons volume and pounds weight, the formula is almost the same:
(lb in grams)/(UsGal in ml) => scaling facator
454 / 3785 => 0.11995 => 0.12 (2 d.p.)
V(USgal) = (0.12) * W(lb) / SG
With a SG of +/- 0.002 and a weight +/- 1lb, the resulting accuracy is
= 0.12 * 1 / 1.002
= +/- 0.12 USgallons
Effects of CO2
The effects of dissolved CO2 is to increase the weight of the beer by the weight of the CO2 without increasing the beer volume.
Since the CO2 is completely dissolved it adds to the SG of the beer. You don't need to worry about this, since it also adds to the total weight, hence the volume calculation is still correct.
However, if measuring with a hydrometer, you may need to be mindful of the CO2 bubbles, which can affect the reading.
If you take a SG reading with CO2, and then again without, you can see how much the CO2 weighs, and compare this with predicted results.
The density of CO2 is 1.82 kg/m3 @ 18.3°C/65°F. The density of water is 1000kg/m3. The SG of 1 volume of dissolved CO2 is then
SG_1_vol_CO2 = 1.82/1000
= 0.0018 SG
So, for the typical beer, 2.4 volumes of CO2 adds
= 1.82 * 2.4 / 1000
= 0.004 SG
So, we would expect the beer with 2.4 volumes of CO2 to have a SG that is 0.004 larger than the degassed beer.
You can use this to compare gassed and degassed beer samples to confirm if the hydrometer is affected by the CO2 bubbles or not. A refractometer is not affected.