If you have enough room in a backpack to put in donuts without forcing them, I would think they would transport OK. If you have to purchase them in one of those large flat boxes, then that is different.
I have carried to work two Bakers Square pies, in their rectangular boxes, in a backpack.
When I mentioned that just now, I was thinking of getting similar boxes for donuts, but now that I think further, how about bringing pie for breakfast? It's fruit.