KYIV, Ukraine — A Russian soldier who pleaded guilty to killing a Ukrainian civilian was sentenced to life in prison on Monday in the first war crimes trial since Moscow invaded three months ago, unleashing a brutal conflict that has led to accusations of atrocities, left thousands dead, driven millions from their homes and flattened whole swaths of cities. In a rare public expression of opposition to the war from the ranks of the Russian elite, a veteran diplomat resigned and sent a letter to foreign colleagues in which he said he had never been so ashamed as on the day Moscow invaded. Since then, a stiff Ukrainian resistance has bogged Russian troops down, thwarting their attempt to take the capital, and the two sides are now fighting village by village in the eastern Donbas region.