Hamiltonian formulation of scalar field collapse in Einstein–Gauss–Bonnet gravity