Just keep your eyes on the road (and assume no one else is). Drive slow and pass the scene. Follow any instructions the CHP or police give you. Typically they will be waving you by and yelling for everyone to “keep moving”. As for the law, unless you do something really stupid, it would be very hard to get cited for this. The police are usually to be busy dealing with the incident to bother citing you unless you are causing a huge issue.
They are the drivers that insist on looking at the scene of an accident or other driving situation instead of driving slowing down all other traffic even though it may be on the other side of a divided highway. If I can’t look at 70mph safely then I won’t look at all. Hope this helps.
Otherwise known as the rubbernecken sightseeren secondary crash causer. Keep your eyes on the road and you won’t have a problem.