This issue still happens in Mac OS Sonoma, believe it or not! Thankfully, the answer @user2069921 gave still works. This was plaguing me for months, but the fix is simple:
Right click on Messages in the Dock, click on the Unread message that appears there to read and/or delete it.
I believe @DeerSteak is correct that is happens when you delete an unread message on your phone. It never appears on desktop, but the Unread state persists.