Another suggestion: Scooter it.
The bike is functional but the drive train cannot transmit power.
So one solution is to scooter along with one foot on the opposite pedal, and your other foot pushing directly on the ground. This can be uncomfortable, so rotating your saddle ~30 degrees to the opposite side from where you're standing can give your hip something to lean on.
You can still use your brakes to slow and stop,and steering is just like normal.
This suggestion is pretty useless if there are any uphills, or any challenging terrain to cross.
If the chain is slapping around, you can tie it to the chainstay with cableties/slipties, or if your equipment loadout is missing these then long grass or flax or even soft twigs can help retain things.
If your chain has a master link, then dropping the derailleur and chain completely off the bike and into a plastic bag can help too.
Related answer Tow it out
If you are riding with someone else then see if they are prepared to tow you out. All the above applies, but you'll be moving faster so secure any loose bits.
The towstrap needs to be long enough that the tow-bike's back wheel clears the towed bike's front wheel. Half-wheeling can bring you both down if it all goes poorly.
A spare innertube or two makes an adequate towstrap. A suitable branch might work but will require some creative mounting to the tow-bike. Fasten the towstrap to the front bike, and the disabled bike is NOT secured - instead the back rider holds the towstrap in their secondary hand and steers/brakes wiht their primary hand.
Communication is critical, and not going too fast. If anything goes wrong, the towed rider simply drops the strap and steers/brakes with two hands. There is no need to tow on a downhill. Do take the easiest line everywhere - remember the tow-bike rider is doing a lot more work than normal, so you will owe them.
Aside - those loose bits can help with repair later on, so don't litter/lose them. If not refitted in the repair, then they can help identify the right replacement hanger to buy.