On the origin of the X-ray emission towards the early Herbig Be star MWC 297