Here you go:

P = F*V

P - Power (W)

F - Force opposing motion (N)

V - Speed of the bike (m/s)

Expanding with 3 forces opposing you on a MTB, rolling resistance, gravity (if climbing/descending), and air resistance, respectively:

P = [(m*g*Cr)+(m*g*sin[x])+(0.5*p*V^2*S*Cd)]*V

m - mass of you and bike (kg)

g - gravitational constant (9.81 m/s^2)

Cr - Coefficient of rolling resistance (refer to explanation A below)

x - angle of incline (degrees, positive for climb, neg for descend)

p - air density (take 1.225 kg/m^3)

S - Front area of rider + bike (take 0.5 m^2)

Cd - Drag coefficient of rider + bike (take 0.5)

Expanding and simplifying:

P = m*g*[Cr+sin(x)]*V+(0.5*p*S*Cd)*V^3

Explanation A:

The most important parameters are m, Cr and x [note sin(x) can be substituted by vertical rise over distance travelled, rise/dist], as these affect the result the most. For fireroad I have approximately calculated Cr ~ 0.03, method which I can tell more about if you want.

This forumla is only applicable to sections of track where you reach a top continous speed for a given power and as such is not useful for track sections where you continously accelerate as you pedal but it is applicable to most of MTB riding. It is a simplified derivative off of a more complicated a = F/m etc formula which is very powerful and can be used anywhere accelerating and all but is considerably more complicated (not the formula itself but application), requires computer solving and not so useful for what you want because you would need to know acceleration.

Below is application of that power formula for calculating what power I make on a local hillclimb I time trial myself on. Note that I can only do this because I accurately know vertical rise of the climb:

Also this exact formula here is used (but in reverse calculating speed given power) for estimating speed difference for different bike setups. You can probably make something similar to this, but calculating power you make as opposed to speed, for any track you ride and it wouldn't be too hard: