I assume most Americans wouldn’t be qualified write-in candidates in their state, so most votes wouldn’t be counted. The state legislatures would have no choice but to appoint electors directly. If no candidate had a majority of electoral votes, the election would then get thrown to the House who would choose from the top 3. If every elector also cast a vote for themselves, then it’s not clear how the House would resolve a 538-way tie, so potentially whoever gets elected VP would become acting president on January 20th.
In Texas, write-in candidates have to file, and include a vice-presidential candidate and 38 elector candidates (with their formal consent).
I think a popular election tie would be resolved by lots.