Finite-size effects in surface tension. I. Fluctuating interfaces