In the United States, when people vote for president, they actually vote for the electors. For instance, the Ohio ballot says the following:

"A vote for any candidates for President and
Vice President shall be a vote for the
electors of those candidates whose names
have been certified to the Secretary of State."

How are Elector College electors chosen for write-in votes for President? Say that miraculously a write-in candidate got 51% of the vote. Would an elector for them be chosen after the vote? If not, does that mean that write-in candidates can never receive electoral votes, despite what ballots say?

How are Elector College electors chosen for write-in votes for President?

A presidential write-in candidate must name the candidate’s four electors when the Declaration of Write-in Candidacy is submitted.

So, in Maine, they are chosen by the candidate himself/herself.

For other states, some have clear guidelines, while others aren't that clear. You may want to check out this article for elaboration.

If not, does that mean that write-in candidates can never receive electoral votes, despite what ballots say?

They can receive electoral votes in states that allows write-in candidates. However it has never happened, so I don't think that the process is super clear in all states. Only some specified the process in registration forms. Write-in candidates don't really have a large chance of winning any state in the first place.

Say that miraculously a write-in candidate got 51% of the vote. Would an elector for them be chosen after the vote?

This article does have a hypothetical example at the end, quite interesting to check it out since the example surely would be better than I coming up with one.

This is going to be different in every state. Note that in most states write-in candidates have to register. I suspect that in those states that require registration, they choose the electors at the same time. In other states they might have to pass a law for it, as it has never happened. Note that 51% isn't necessary. 40% might be enough this year. In Utah, even 30%.

In addition, candidates for president and vice-president of the United States shall also file with the secretary of state by that seventy-second day a slate of presidential electors sufficient in number to satisfy the requirements of the United States constitution.

If they don't, then they'd fail certification and would not be eligible for write-in in Ohio.