What is the ruling if a Muslim man working in the army of a Muslim country, kills a Muslim man working in the army of a Kāfir country in a war between these countries? What is the ruling in the opposite case?
Shaykh Abū Bilāl Al-Ḥadhramī told,
Joining in the armies of bilādul-Kufr is not allowed as they order the army men with that which opposes the Sharīʿah (like removing the beards). 
As for the answer to the question, if the Muslim country transgresses on the Kāfir country then the sin is upon the muslim who is in the Muslim country’s army and if the Kāfir country transgresses on the Muslim country then the sin is upon the muslim in the Muslim country’s army. And a muslim should not fight along with the transgressing party, he should come out of the war if his people are transgressing on the other.
On being asked, how a muslim country transgresses on bilādul-Kufr, as the life and wealth of the kāfir is ḥalāl; the Shaykh said, if there is an agreement between them and if the muslim country breaks this agreement and attacks the bilādul-Kufr then this is transgression.
End of Shaykh’s speech.
See the following fatwā from the Permanent Committee regarding working in the army of a muslim country who orders with that which opposes the Sharīʿah. This also applies to a person working in armies of bilādul-Kufr.
Allāh knows the best.
Compiled by: Abdun-Nūr al-Hindī
 Ash-Shaykh Al-ʿAllāmah Ṣāliḥ al-Fawzān حفظه الله, in a beneficial treatise on al-Walāʾ wal-Barāʾ (Allegiance and Disassociation for Allāh’s sake) states,
Furthermore, Allāh forbade the believer from supporting the Kuffār, even if the Kuffār are blood relatives. Allāh, the Exalted said,
“O you who believe! Do not take your fathers and your brothers as Awliyāʾ, if they love disbelief (Kufr) instead of Faith (Īmān). If any of you do so, they are wrongdoers.” Sūrah at-Tawbah 9:23
Allāh, the Glorified, forbade Muslims from supporting the Kuffār, and the enemies of the ʿAqīdah. The Glorified, commands us to support and love the believers. Allāh, the Exalted said,
“Your [real] friends are Allāh, His Messenger, and the Believers, those who establish the Ṣalāh and pay the Zakāh and bow down [submit themselves to Allāh]. As for those who turn to Allāh, His Messenger, and the Believers [for friendship], it is the party of Allāh that will certainly triumph.” Sūrah al-Māʾidah 5:55-56
For further reading: https://drive.google.com/file/d/0B4re9UeCHGCURlJscG5EeTVWNVE/view?usp=sharing
Also, Shaykh Yaḥyā al-Ḥajūrī حفظه الله, in his introduction to the book, ‘Guiding the Best of People to the Obligation of Making Hijrah from the Lands of the Disbelievers’, by Shaykh Abū ʿAmr ʿAbdul-Karīm al-Ḥajūrī حفظه الله, mentions that from the most significant harms and dangers of residing amongst the disbelievers (which obligates making Hijrah) is,
“Oppression of the Muslims especially when wars occur between the Muslims and the disbelievers or when something that does not please them occurs from some Muslims. You see the disbelievers oppressing the Muslims and rejoicing over their mishaps and violating their honor. And they send forward the Muslims to fight their Muslim brothers in the other lands as they did in the Iraq war and others so if something harmful occurs it occurs to the Muslims within themselves while the disbelievers give the orders.”
For further reading: https://drive.google.com/file/d/0B4re9UeCHGCUaG1XY041d0RkeE0/view?usp=sharing