For the same gradient road, at the same speed, at two different gear settings, power required (energy input per unit time) is the same. The gear friction will not change much with modern efficient bicycles (Ref). Why does power remain unchanged?
Power equals Force x velocity:
$P = Fv\tag1$
or in the case of rotation:
$P = \tau \omega\tag2$
Where $\omega$ is rotational speed on the axis you are pedaling on. As cadence increases, i.e. pedaling side sprocket is smaller, the $\omega$ on the pedaling side increases, but required torque $\tau$ decreases proportionally, therefore power remains the same.
If, however your speed increases, air resistance is bound to be a factor, so going faster will require torque $\tau$ to decrease slower than rotational speed increase, thus increasing power input. This is because torque $\tau$ is related to required forward force by:
$\Delta\tau = r_{w}g_r\Delta F_f/r_s \tag3$
where $r_w$ is the radius of the driven wheel, $g_r$ is the gear ratio between the driven wheel sprocket and the pedal sprocket radius at which one is pedaling, and $F_f$ is the force required to move the bicycle forward against your mass, parts friction and air resistance, $r_s$ is the radius from the pedal to the centre of the driving sprocket. Power will therefore increase at the rate that torque fails to keep up with pedal sprocket rotational speed increase.
If you cycle uphill, but maintain the same speed as on a flat road, you will have to expend more power, why? You are gaining gravitational potential energy. For the same bicycle speed and same cadence, in addition to the power required to move the bicycle across a flat road, you are lifting your body and the bicycle to higher ground, so you will have to use more power. This will be manifest in the higher torque input into the pedals in equation $2$ above.