Safely mounting television or shelves above breaker box
Code isn't really relevant unless you were to block access to the panel (within 3 feet in front). Just don't hit any wires. Use screws that penetrate no more than about 1-1/4&quot; into the lumber. All wires should be deeper than that.
To respond to the hand-wringing about mount integrity...

A 5/16&quot; screw (properly piloted) into framing an inch will hold hundreds of lbs. of force without issue.
Four of them will hold a horse. If you're still worried, use six. Most mounts have extra space where you can drill more holes.
Mount manufacturers over-spec their kits for liability (damage and injury) and to protect their reputations. That doesn't mean you need to go so deep.