I have tested a LaunchAgent and companion Zsh script running on macOS Ventura 13.6.6 and it opens a dialog when the battery level descends to a specified value. This should work fine on Sonoma too, but I have no battery devices currently running Sonoma to test.
When the LaunchAgent runs it will pass your 20% value as an integer to a Zsh script. That script will test if you are off or on the charger and exit if on the charger. However, if you are still discharging the battery, you can dismiss the dialog and in the next time cycle, the dialog will reappear until you connect the charger. The testing for battery level is not continuously running and only wakes up and tests on the cycle you set in the LaunchAgent .plist.
The following alert appeared because I had set the LaunchAgent to warn when the charge level dropped below 96 percent. I couldn't wait all day for it to drop to 20%. I chose that 300 DPI battery icon for your stated 20% level…
The alert uses the default dark appearance mode text color (white), and when a Light appearance is chosen, the text will be black.
Here is the link to the LaunchAgent_BatteryAlert folder on Google Drive.