Yes they can in principle, though likely to be very rare and unstable. Also stars can be donut shaped as well, young stars, in principle.
The usual idea most people have, is the same as Hal Clement's Mission of Gravity he explores the idea of a planet spinning very rapidly so it looks like this:
However since then we've found rapidly rotating dwarf planets in our solar system. And the ones found so far are a bit different, they are triaxial spheroids.
If a planet rotates very quickly, it can look this - this is an artist's impression of a dwarf planet in the Kuiper belt:
They rotate around their minor axis, the shortest of the three axes.
It turns out that there are two possible solutions, as the spin rate increases. You can get an oblate spheroid, or a triaxial ellipsoid - the solution "bifurcates". But the triaxial ellipsoid is the most stable of the two as Jacobi found out in his paper published in 1834 Figures of Equilibrium - Historical Account* - Chandrasekar
Then as it spins faster, it can turn into two spheres joined together. This is the scenario of a binary planet.
GRAVITATIONALLY LOCKED BINARY PLANET
If two planets are gravitationally locked to each other, in the same way as Pluto and Charon, then tidal effects no longer matter.
They are just permanently distorted. You could in principle even have an Earth sized planet almost touching our Earth - even with a shared atmosphere and ocean.
Though we don't know any Rocheworld planets yet, there are many contact binary asteroids. These are too small to be rounded under their own gravity, but are approximately the shape of an overcontact binary.
And comets also, this is 67P/Churyumov–Gerasimenko which is also approximately the shape of an overcontact binary
Also many contact binary stars are known, again including "overcontact binaries" also like these asteroids and comets, so close together that their atmospheres overlap - the first discovered W Ursae Majoris.
As it spins even faster then in theory anyway, a planet or star can turn into three or even four spheres joined together to make an "overcontact ternary" or "overcontact quarternary" planet or star, or you could have a donut shaped planet too, though so far we haven't found anything like this:
This is an animation someone did of the last possibility the "hoopworld"
But thin hoops like this are unstable and easily break up into droplets.
Thicker hoops like this visualization from io9 though can be stable.
I shouldn't think there are many of these in our universe :). Needs very special conditions to form. But - not impossible apparently.
Here is a youtube video of a Moon of a donuut planet:
You can also get donut shaped solutions for end state of a collapsing gas cloud, which are stable, in principle. So, you could have young toroidal stars as the author suggests in this paper : General Relativisitic Sturcture of Star Toroidal Systems (1992).
Anders Sandberg's fun article explores many aspects of life on a donut shaped planet - and the orbits of satellites and moons around such a planet.
and quora answer Why are planets round? - I've trimmed down that answer a bit for this one, left out the triangular, square and pentagonal planets idea.