It might be a hardware issue, but consider the possibility that something installed on the Mac is conflicting with the latest version of the MacOS that is being upgraded to, but worked ok with earlier versions. There are ways to test this, including booting into Safe Mode. A drastic step, maybe not for everyone, but a step I have successfully taken in a case similar to yours, is to make two backups that you have checked are sound. Then erase and reinstall the MacOS, create one generic administrator user (call it "admin") and upgrade to the desired version of the MacOS, but install nothing. You now have a generic, vanilla Mac, much like a brand new unit from the factory. If the problem is present, it is likely to be broken or faulty hardware. If the problem is gone, then migrate users and account and files, but nothing else (no software, no settings), retest for proper behavior, then reinstall software bit by bit, testing after each install to ensure the problem has not returned.