I recently bought a 2017 13" MBP new and had something similar happen. Took it back to Best Buy immediately and exchanged it for a 2019. I read that some models have had issues with the ribbon cable that connects the display to the motherboard. I didn't want to take my chances.
The reason I singled out the ribbon cable is because the issue sounds like a graphics related issue. I have had graphics cards fail and exhibit similar symptoms, or had HDMI or MDP cables fail and do something similar.
iFixit explains. Starting with the 2016 MacBook Pro, Apple has used a pair of flexible ribbon cables that are pulled tight every time you open the lid on the computer. That may be damaging them over time.