CAIRO — Sudan’s military on Friday retook the Republican Palace in Khartoum, the last heavily guarded bastion of rival paramilitary forces in the capital, after nearly two years of fighting.