The Rev. Adam Hamilton, a centrist Democrat, ousted Senator Roger Marshall, a Republican who was bogged down by President Trump’s unpopularity.