I'm using an Acer Aspire A515-57 laptop with Ubuntu 22.04. Normally I work in a partition within the same device in Windows, and the default music player works like that, so I can keep the laptop closed and not waste too much battery while still listening to music.
I checked the plugins and it seems like there isn't anything specific for this. There's another user that asked a similar question here but when I accessed to the power setting, there's no option to do nothing when lid is closed, or anything related to closing lid. I have shared a screenshot of the settings (In Spanish since it's my native language).