This writeup targets macOS Sequoia and is for people like me who got used to other operating systems but have to tolerate macOS's brain damage for work.
System Settings → Battery → Options... → Prevent automatic sleeping on power adapter when the display is off (on)
Install and use Fermata to keep laptop awake on battery without an external monitor attached.