Is it allowed to let the engine of an aircraft idle without a pilot in the plane. (For both helicopters and aircr).
Would there be a difference between a C172 and a 737?
You won't see it done in the fixed wing world unless the aircraft is tied down or otherwise securely restrained (like when you tie off the tail to something when hand starting your no-starter taildragger; some pilots just use chocks or parking brakes to hand bomb their airplane, but it's a terrible idea).
However, it's common in the helicopter world especially in bush operations. With the collective and cyclic friction locks tightened down and the engine in ground idle, it can't really go anywhere and a pilot who lands in a remote area without assistance to hook up a sling load or lug something on board will often do it without shutting down.
I'd say no, you're likely to be busted under 91.13...
(a)Aircraft operations for the purpose of air navigation. No person may operate an aircraft in a careless or reckless manner so as to endanger the life or property of another.
Having had a parking brake slip on a small GA aircraft once or twice myself, I can say its generally a bad idea regardless of regulations.
It would be very difficult for a lone pilot to hand prop start an aircraft without this occurring for some span of time, which would lead me to conclude that it is not forbidden.
Generally speaking, no. Legal or not, it is a very bad idea.
To add some detail, in the Navy we would "hot switch" pilots occasionally in the EA-6B - shutting down the left engine on the pilot side, but leaving the right one running. In these cases the plane was chocked, (chained when shipboard) and there was always an NFO in the right seat to monitor the engine and shut down if needed during the minute or so it would take the next pilot to climb in.
Otherwise the only other time you would not have a pilot in the plane is when a turn qualified engine mechanic was there instead, supporting maintenance. I would imagine similar policies are in effect at the airlines.