A quick and simple way is to use an application called Black Hole.
https://existential.audio/blackhole/
Step 1:
Once you have installed this, open up audio MIDI Setup

Step 2:
Add a Multi-Output Device as an option and tick both MacBook speakers AND BlackHole.

Step 3:
Then open up sound preference and route the sound through the multi output device.

Step 4:
Then select Black Hole as the audio input in OBS Studio.
