In an emergency, the crew can do pretty much anything that they feel is necessary to get the aircraft safely on the ground. If they end up doing something really bizzare, they may have to justify their actions, but short of that, no one is going to question what they do. As far as what is the penalty for violating a SID or a STAR - it is the same as violating any other portion of an IFR clearance. It can involve a license suspension for a period of time and maybe a fine. In other words, it's something that you really don't want to do. In the real world, a SID or a STAR is something that you frequently get, but ATC often gives you "shortcuts" so as to not require you to fly the entire procedure. For most airplanes, there are very few emergencies which would require the crew to put the aircraft on the ground quickly. I can only think of two or three right off the bat - a fire, a total electrical failure in IFR conditions, and (depending on the type aircraft) perhaps a battery thermal runaway - these are all very rare events, but of course, they can (and have) happened. Are there others? Of course, but most other emergency scenarios give the crews plenty of time to land. It must be remembered, that bad things can happen when flightcrews get rushed.