Why is the asteroid belt shaped like a triangle?
It's not. The image doesn't show the main asteroid belt. It shows the Jovian Trojans (in green) , and the Hilda Asteroids (in red). 

The Hildas are a dynamical group of a few thousand known asteroids in elliptical orbits that are locked in a 3:2 orbital resonance with Jupiter, and reach aphelion coinciding with the regions near Sun-Jupiter Lagrange points L4, L3, and L5 in succession. 



"Animation showing Hildas with 3 indicated orbits" from "Asteroid (and Comet) Groups", Petr Scheirich, Retrieved 2020/02/14.

In accordance with Kepler's Second Law, objects in elliptical orbits move slower near aphelion than perihelion, and as a result, when you just look at the Hildas, they bunch up near the Lagrange points, and the pattern they appear to show at any one time resembles a triangle.

A more complete view of all the Asteroids inside of Jupiter looks like this.