You carbonate partially filled bottles as if the bottle were full of beer, so if you have 1 liter of beer in a 3 liter bottle, you carbonate as if you had 3 liters of beer. Here's why.
The amount of carbonation is measured by the equivalent volumes of CO2 dissolved in the beer. So a beer carbonated to 2.5 vols, has 2.5 times the volume of CO2 dissolved compared to the volume of beer (if the gas were at standard pressure and temperature.) To get that 2.5 volumes dissolved in the beer requires the gas in the headspace to reach equilibrium with the gas in the beer - so there also has to be 2.5 volumes of gas in the headspace. So, when you carbonate, you actually carbonate using the volume of the container, not the volume of the beer. Normally the two are so close that it's not worth distinguishing.
The same is true for kegging - you use the same pressure to carbonate no matter how much beer is actually in the keg.
In this case, even though the bottle initially has only 1 liter volume, the volume will expand to 3 liters once the yeast start producing CO2, so carbonation calculations have to target the 3 liters container volume rather than the beer volume.
Now it does get a little more involved than just scaling up the carbonation sugar based on the container volume, since there is already dissolved CO2 in the beer which will also equalize in the headspace. Amount of CO2 in the beer after fermentation depends upon the temperature the beer is fermented at. The formula, from brewersfriend priming calculator, is
co2_in_beer = 3.0378 - (0.050062 * temp) + (0.00026555 * temp^2)
Where temp is in °F. So, for beer fermented at 72°F the CO2 already in the beer is 0.81 vols.
Since this will eventually equalize throughout the whole bottle, we can recompute the volumes of gas that would be when the bottle is filled
initial_co2_bottle = co2_in_beer * volume_of_beer / max_volume_of_bottle
For example, our beer fermented at 72°F storing 1 liter in a 3 liter bottle:
initial_co2_bottle = 0.81 * 1 / 3
= 0.27 vols
To target of 2.5 volumes, we need to add priming sugar to make up the difference between the volumes already in the beer/bottle and the desired target:
priming_volumes = 2.5 - 0.27
= 2.23 vols
When priming with sucrose (table sugar), half of the weight of the sugar is converted to CO2. And 1g of CO2 per liter corresponds to 0.5 volumes. (Source.) Which gives this formula:
vol_co2 = 0.25 * weight_of_sugar (g) / volume_of_container (l)
Re-arranging this to find out how much sugar is needed to reach a given volumes:
weight_of_sugar (g) = vol_co2 * volume_of_container (l) * 4
E.g. to achieve the 2.21 volumes needed above
weight_of_sugar = 2.23 * 3 * 4
= 26.8 g
To carbonate 1 liter of beer at 72°F in a 3 liter bottle to 2.5 vols you would need to add 26.8g of sugar to the bottle.
Combining all of these formulae into one, we get:
g = (c - ((3.0378 - (0.050062 * t) + (0.00026555 * t^2)) * b / v)) * 4 * v
- g the weight of sugar needed (g). Divide by 0.286 to convert to ounces.
- c is the desired carbonation (vols CO2)
- t is the fermentation temperature of the beer (°F)
- b is the total volume of beer (l)
- v is the total maximum volume of the bottle or other container the beer is in (l)
Working this with our example:
g = (2.5 - ((3.0378 - (0.050062 * 72) + (0.00026555 * 72 * 72)) * 1 / 3)) * 4 * 3
= 26.8 (g)
If you want to add the sugar to the beer in the bottling bucket, then just use b = the total volume of beer in the bottling bucket, and v = the total volume of all the bottles the beer will be put in.