There are so many things to consider when you calculate one such thing, and it would again involve a lot of data, equations and that too with subtle variations in data.
For an example, there are people walking at different speeds, there would be differences, especially between walking and running.
You know, with trekking/hiking, its practically hard to draw a line between walking-like pace and almost-running-like a pace, and to add to mathematical complexity, there is another brisk walking kind of thing, that too considered along with Physiological data of the person? Like Height, weight, etc? So, the Highly accurate estimations are specific to the individual.
To consider those details for getting approximate measure of Calories burnt during a hike, a detailed bio-mechanical study of walking (and running) on steep gradient would be required for an appropriate characterization of the gait and for a clear identification, from the measure of contact times, of the transition from a walking-like to a running-like gait when the differences between walking and running tend to disappear. There has been a long debate over if the Speed really has anything to do with Work done, but I personally feel that, speed does play a (minor) factor in changing mechanical efficiency of human movement, may be a runner can tell better.
It could have been better if one consider the analytical data about Level Walking and Level Running and, how and why the difference between the Work done in both the case is subtle.
Speaking of gradients, When walking or running on positive gradients (ascends), both increases as the function of the incline (Elevation). So we can actually get away with obtaining the closer approximations if we consider walking, based on the fact that the approximation of considering just the mechanical potential work (and disregarding the kinetic one) because it is assumed that beyond a given gradient the rise (or descent) of the center of mass (consider, the load that you carried?) is the prevailing contributor to the mechanical external work.