How to connect Ms0, ms1, ms2 from A4988 driver to arduino mega?

If you don't want to change the setting later then connect the pins to Gnd or Vcc just like you had set the jumpers. Else connect to Arduino output pins and do digitalWrite() as required.