Here’s what you need to know.
Nine states—Arkansas, Hawaii, Louisiana, Mississippi, Nevada, New Mexico, Oklahoma, South Carolina and South Dakota—do not accept write-in votes.
Eight states—Vermont, Wyoming, Oregon, New Hampshire, New Jersey, Iowa, Delaware, and Alabama—allow write-in votes for anybody, and count them.
The other states—33 of them—allow write-in votes but only count them when cast for people who have registered in advance as write-in candidates. The requirements for registration vary from state to state. Some states require lists of voter signatures. Some require candidates to declare well in advance (the deadline for registering as a write-in candidate has already passed in some states).
So…you can write in a candidate in most states but your vote may or may not count. Better be sure where you are before you do it.