The temperature lapse rate, or elevation gradient, captures the thermodynamic effects of moving air masses vertically. Google for dry-adiabatic and wet-adiabatic to get better explanations. Although the theory applies for free air masses, the concept is generally used also for 2m temperature in varying terrain. How it is calculated depends on what information you have, the simplest is of course if you have some measurements at different altitude, simply fit a line and estimate the slope.