It’s air horns
Large trucks use compressed air to operate thier brakes because it would be nearly impossible to operate the brakes the way a car does due to the number of wheels and how braking is done on thier trailers.
That means nearly all trucks have a large amount of compressed air stored in tanks ready for use.
The pull chain type horns are a air horn the has a valve that opens when you pull the string. The horns are mounted on the roof on alot of trucks and trains as such the hose with the air runs in the roof. That makes it a easy and cheap spot to put the valve.
With the cheap cost of electrically operated air valves alot of truck designs have moved to a button and relocated the horns to locations behind the bumper.
Some brands like “usually the American brands” have kept the roof horns and chain for brand visual consistency and customer appeal “e.g:look just like the truck your daddy drove”.
Latest Answers