It would depend on the state law. I doubt there is a state law written for this eventuality in most states though. So each state would send it's electoral votes to Washington to be opened in a joint session. What would happen is that if Trump were to be the nominee and were to win, when it came time to certify him for the election by the joint session of Congress, there would be an objection (as we saw in 2020). The chambers would vote on the objection. This is where it probably gets interesting as for a constitutional crisis. The House and the Senate would both debate this. What should happen is that if Trump is in prison, his name is taken out of consideration. Would it happen? Probably not. The GOP is completely devoid of character, scruples, and is stocked top to bottom with hypocrites who hate babies and are mean to puppies.
But Here is what I think would happen. As the votes for vice President are counted, the vice president, presumably, would get certified as VP. The 25th Amendment would then be twisted and turned to install the VP as President Elect. The 25th only is used for a seated POTUS/VPOTUS however. But I think the Court will extend that to cover the President/VP Elect though. Its a gray area.
I would imagine there is a school of thought as to where the Democrat with the 2nd highest number of electoral votes would get a sniff for President (in this case a 2nd term) but that wouldn't fly (I believe).