It is not obvious whether they are stable, yet thin ones (Hoops, having a large hole at their center) are not. It is permissible by physics, but the conditions creating them are very unlikely. This is a case study of such configuration.
There is a certain range of axial rotation speed which could turn a fast-spinning planet into an ellipsoid, and a narrow range which "stretches" it further into a torus. It is interesting to find-out how axial rotation can be increased to allow that. Maybe a series of asteroids coolisions can do the trick? The site refers to the shape as somewhat sensitive to wobbles which make the torus tear apart into two spherical planets orbiting each other, so the series of collisions is a too delicate operation?.
The ring may itself be unstable, in particular to a “bead” instability
where more and more mass accumulates at some meridians than others,
leading to breakup into two or more orbiting blobs.
It looks like a toroid planet is not forbidden by the laws of physics.
It is just darn unlikely to ever form naturally, and likely will go
unstable over geological timescales because of outside disturbances.