Mr. Trump leaves as a newly appointed special counsel begins looking into any ties between Russia and the president’s campaign.