First and second Hadamard variational formulae of the Green function for general domain perturbations