Yes, but only up to a certain date. In my state I think ballots can't be changed in the 60-day window before an election.
So if the election were Nov 8, then the deadline for changing the name on the ballot would be something like Sept 9th.
Then after Sept 9th, if a candidate became disqualified (by incapacitating illness, death, or being forced out by the party), legally it would be too late to put a replacement name on the ballot. However in NJ the Dems have gotten around this law at least once.
Every state is different!
That’s the genius of our system.