That is a very interesting question. I doubt the railroads themselves ever issued official weapons at any point, with the exception of as others pointed out mail cars and cars carrying money (among other things, spend money? some things with railroads never change *lol*). About the only other personnel I could see being armed might be railroad police, and that would (I assume) be through the company.
On the other hand, especially in the 19th century, I would bet a lot of rail personnel had guns on them. In the initial decades, there would have been hostility from the native Americans and even without RPO or money transfer on a train, there were enough bandits around who would rob the passengers (among other things, rail travel was pretty expensive back then, so the people riding were often going to be somewhat well off). Not to mention robbing freight trains of whatever they could. Even in the 20th century I could imagine railroad personnel having guns working in more rural areas, if only for protection.
On the other hand I have a story of more urban activity. My mom's sister in law's father was a motorman on the old 3rd ave el (this would be in the 30's-40's). He told stories he heard from towermen who worked at the Willet's Point tower on the 7 line (near where Shea Stadium was and now Citifield). The area had been a landfill/dump and is also a swamp (Flushing Meadows *lol*). Anyway area was full of rats and the towermen there would often be armed and would spend time shooting rats. I doubt the TA would have issued the guns *lol*.