This term is a reference to the folding pocket knife (larger than a "pen knife") once known as the jackknife whose blade can be folded back into its handle. Visually, this folding resembles a jackknifed truck and trailer.
The name "jackknife" comes from the heyday of seafaring. Sailors commonly carried these tools and they were associated with sailors. Because of its link to the Mariners who carried them the night became known as the jackknife which etymologist believe is a reference to a sailing vessels flag or Jack staff.
The use of jackknife as a verb (sometimes jack-knife) goes back to American English in the Revolutionary war days when it too on the meaning "to stab." Around the time of the Civil War, it also had the meaning of "to fold or bend" your body as with the knife.
Starting around 1922, it started being used to describe a kind of swimming dive.
It didn't become something used to describe truck accidents until the second half of the 20th century.
|3 divers, the topmost one doing a jackknife|