But then you have to deal with a VM on top of the host macOS. IMO it's way easier to install brew, install an up to date copy of bash (which is more recent than Ubuntu has), and coreutils, and just use macOS. Having to do gls occasionally (for GNU ls) is minorly annoying, but way less work than a whole freaking VM.
https://formulae.brew.sh/formula/bash shows version 5.2.15.
https://packages.ubuntu.com/kinetic/bash (well http://changelogs.ubuntu.com/changelogs/pool/main/b/bash/bas...) shows 5.2.1+debian/ubuntu patches.