I'm not sure what you mean by a formula. It's pretty simple. It's just a matter of mass times distance.
The aircraft has a Dry Operating Weight and a Dry Operating Index reference to a fixed datum. Each item loaded then has a moment which is its mass times its distance from the datum.
After everything is loaded you have a total mass and a total moment. Divide the moment by the mass and you have the CG expressed as a distance from the datum. Find out where that is, divide it's distance from the mean leading edge by the mean chord and you have a % MAC
To determine MAC ZFW, simply leave the fuel out of the equation, and for landing use takeoff fuel- trip fuel.
Simple!!
('Course, all I do is sign the Computer Load-sheet!!)