You can't. At least, not in any accurate way. The reason being that you have too many variables. Each variable adds a significant amount of error due to inaccuracies in measurement to your calculation. This might be a nice math problem, but as a physics problem, it has little application to the real world. My WAG is that the error in your calculation would probably exceed 50%.
If you want to determine fuel consumption, try just accurately measuring how much fuel is being consumed at any given moment in time. Your engine's fuel pump will "know" this information based on how hard it needs to work. It's a pretty trivial task to convert this information into something usable if you're in the process of designing a car's computer, which is why this feature is included in many newer cars.
As for the math that would give you a "miles per gallon" number, it would go like this:
For argument's sake, consumption rate R is measured by the fuel pump in ml/second. For the time being, let's measure speed (V) in metric as well, since that too is being measured accurately. Speed needs to be reduced to meters/second to match the fuel pump's consumption rate figures, allowing them to cancel out. The amount of fuel used over any distance would be:
Consumption = R / V
and Consumption would be measured in millilitres/meter. Multiply by 1000 for litres/km.