Functional methods in thermofield dynamics: A real-time perturbation theory for quantum statistical mechanics