My suggestion is to take it to an Apple Store or Apple Authorised Service Provider as soon as possible because the machine is borderline vintage and when Apple announces that it is vintage then it will no longer be serviceable at all by any Apple service provider.
Although you've run AHT (Apple Hardware Test) there is also ASD (Apple Support Diagnostics) which are much more in-depth. Running this is something Apple service provider can do easily and may provide more information.
Something you'll also find they'll do at an Apple service provider, especially at an Apple Store is boot the computer from a KG (Known Good) hard drive with macOS installed. Which can be left to run for a period of time to preclude any operating system issues with a simulated load.
You could do this yourself if you'd prefer to first, by installing macOS onto an external hard drive or USB stick (I can give instructions if needed for this, just ask). If you don't have a spare drive where you could do this you could instead take a backup of your data and reinstalling the operating system, if this doesn't resolve the issue it only leaves a hardware issue.
One final though, have you noticed if this issue happens while on battery only, or also when on power adapter, if the former (battery only) it could be that the battery is failing and unable to sustain peak power, and a replacement battery could resolve the issue. However this issue will normally show up in the System Information app which you can access by:
- Open the Apple menu
- Hold Alt and click System Information
- Navigate to power on the left side
- Look for the section "Health Information"
- Check the cycle count is less than 1000
- Check the "condition" says "normal"