Right after starting Sun and Moon save and quit. Restart, go to the Mystery Gift menu, type the serial code "SMWYOSHISEGGSNES". Typing this code will grant you an egg. This egg will be the first Pokemon in your party, and once it hatches, you'll be given the choice whether or not you want Yoshi to follow you. Choosing yes makes it so that Yoshi will follow you and act as a 7th party member, and interacting with him heals all your Pokemon. Choosing no allows you to play as Yoshi, while the character you were meant to play as will be sitting on the bed in the PC's house.