Use iPhone as sound output device for MacBook [duplicate]

This can be done using an app called Airfoil.

Description of Airfoil app:

Stream any audio from your Mac all around your network. Send music services like Spotify or web-based audio like Pandora wirelessly to all sorts of devices, including the Apple TV, HomePod, Google Chromecast, Sonos devices, and Bluetooth speakers. You can even send to iOS devices and other computers.

This supports sending audio to iOS devices and is also available for Windows.

The corresponding app for iOS to revive the audio is Airfoil Satelite.