I already have Y, and also want to get Sun/Ultra Moon. Gyarados is now able to learn Hurricane (and get Flying STAB) from Gen 7 onwards. Should I get the Magikarp/Gyarados in Y, then transfer it with Pokémon Bank to Sun/Ultra Moon when it's reach level 48 (where can learn Hurricane), or catch it in Sun/Ultra Moon and transfer to Y when it learned Hurricane? (Edit: To be exact, the Gyarados will be transferred into my Y game)
You definitely want to catch the Magikarp or Gyarados in X/Y and then trade to S/M/US/UM once it learns Hurricane, as it is impossible to transfer Pokemon from Sun and Moon or Ultra Sun and Ultra Moon back to X and Y.