Republicans endorsed by former President Trump fared poorly in this week’s midterm elections, a sign that his influence may be waning or becoming counterproductive.