The two-loop energy–momentum tensor within the gradient-flow formalism