From the chemical side, the answer is quite simple.
When burning 12g of carbon, this carbon takes 32g of oxygen from the air and so forms 44g of CO2. The reason is simple: One carbon atom weights 12 units, one oxygen atom 16 units. So a CO2 molecule weights 12+2*16=44 units.
So, if you know how much carbon is in one liter / gallon / kilogram of fuel, you can calculate how much CO2 is released when you burn it.
Example:
Ethanol: A molecule of C2H6O weights 2*12+6*1+1*16=46 units and contains 2*12=24 units of carbon. So, 1kg of ethanol contains 0.52kg carbon, which turns to 1.91kg of CO2. The density of ethanol is 0.789kg/l, so 1 liter ethanol generates 1.51kg CO2.
Diesel (and gasoline) are mixtures of different substances, so it's hard to calculate the amount of carbon inside without knowing the composition of that fuel. So, I found a lower value for diesel on Wikipedia:
Diesel: 2.62kg CO2 per liter of fuel
Gasoline: 2.32kg CO2 per liter of fuel
Ethanol: 1.51kg CO2 per liter of fuel
LPG: 1.8-2.0kg CO2 per liter of fuel
Note: LPG is a mixture of butan and propan, but the ratio can vary heavily.
The more important question is:
How much fuel do you actually burn?
We all know the mileage stated by the manufacturers have nothing to do with reality. Highway consumes less than city, mountainous routes more than flat routes. Having more people / luggage in a car does not consume much more on the highway, but in the city / mountains, it does. Weather, altitude and driver behaviour have effects, too.
The age of the car doesn't matter (except it has a generally worse mileage). An old engine may spit more unburnt/partially burnt fuel, but that's negligible compared to the total amount of burnt fuel.
Finally, your mileage can vary a lot by outer circumstances.
So, the most accurate value can be obtained if you exactly know how much fuel you burned:
kgCO2 = kgCO2perLiter * litersBurnt
The next best value can be calculated from your experience what your average mileage is, and then you can use exactly your formula.
If you want to split the CO2 among the people in the car, do it. It depends on what you want to express with your calculation.