If your Yamaha keyboard has a USB interface then you can connect it to a USB port on your Mac. Launch GarageBand and (the chances are very good that) the keyboard will be recognized as a MIDI input device. If your keyboard is an older model with just a MIDI connection then you will need a MIDI to USB cable; these are avaialble but not widely used anymore. Once the keyboard is attached and recognized in GarageBand there will be one track already created as a default in your first empty project. To record you will need to click the red circle at the bottom of the window.
From the panel on the right you will be able to select any other sound that you can patch to successive tracks where you will be able to use your keyboard to 'control' the sound (hence the term: MIDI controller).