HARRISBURG, Pa. — In the same spot where he spoke to thousands of people at a raucous State Capitol rally demanding an end to pandemic restrictions in April 2020, Doug Mastriano appeared on Saturday before a crowd of just a few dozen — about half of whom were volunteers for his ragtag campaign for governor of Pennsylvania. Mr. Mastriano, an insurgent state senator who in the spring cruised to the Republican nomination, is learning this fall that while it is one thing to win a crowded G.O.P. primary on the back of online fame and Donald J. Trump’s endorsement, it...