Well the Krajina Express was only viable because the opposition had no significant air power and apparently couldn't bring heavy weapons to bear on it. The Serbs had another, smaller armoured train that got ambushed by Bosnians with a T-55 tank and that was the end of it. This suggests to me that the likeliest scenario for a "modern" (1960s onwards) armoured train would be counter-insurgency. Perhaps you might get a situation where logistics had to go along a railway, and the armoured train fulfilled the same role as the convoy-escort gun-trucks seen from Vietnam to Iraq.
Imagine this: a big country gets involved in a counter-insurgency campaign in a small country. The only route from the only port to the combat zone passes through an area of precipitous wooded mountains. The only roads through this area are narrow, crumbling, dangerous and vulnerable. Helicopters can't carry the sheer volumes of stuff neccessary, and it's impossible to build a landing strip at the destination. The only way through this area is a colonial-era railroad, driven through at enormous cost in blood and treasure in the 19th century. The Insurgents are as aware of these factors as the Army, and are determined to disrupt railways operations by any means possible, but the same factors that force the Army to use the railway also mean that the Insurgents can only bring to the party what they can carry: small arms, explosives and hand-tools.
As has been rightly pointed out, the biggest problem in armoured train operations is not protecting the train but protecting the track. The location of the track is fixed and known and it's impossible to physically prevent access along it's hundreds of miles. Insurgents could rip the track up or block it hours before the train arrives and contrive to trap it by blocking the rail miles behind where it stops. However this cuts both ways. The location of the track is known to the Army as well, and the insurgents have to come out of the cover of the forests and remain in a fixed location to work on it. This means that the Army can dissuade or prevent many attempts by patrolling the track, using aircraft/helicopters/UAVs according to era and preference.
The Army has large resources to bring to bear for arming and armouring the trains, but one thing it can't do, at least in the initial stages of the campaign, is choose the trains themselves. Importing a modern loco wolud be hugely expensive and difficult and if the campaign is initially expected to be short and sharp, then there may be a reluctance to commit to such a long-term investment for several years. This means that the train is likely to be, at best, a 1950s vintage item, imported second-hand from Europe in the 1960s and maintained to a variable standard ever since.
For armament against Insurgent attacks, one thing that immediately strikes me as useful for both it's lethality and it's psychological impact is the minigun. The normal objection to Gatling guns for ground use is that they waste ammunition and over-kill a point instead of covering and area. However, a train carriage has more space and weight capacity than any AFV, so it could easily carry a useful amount of ammo and could even be equipped with a small generator to power the guns and make them independent of batteries.