Elections are handled at the state level, not federally. How exactly this works will depend on the state.
For example, if the state uses paper ballots counted by machine, doing this would mean marking two selections for President (or Governor, or Senator, or whatever) - the candidate themselves and the write-in space where you've written the candidate's name. Two things could happen here:
- Such an "overvote" would be considered invalid and not counted at all.
- The machine will be unable to count this vote, so it will initially not count as any vote until it can be manually reviewed. A human reviewer would recognize that it is a vote for the named candidate, and it would count as one vote for that candidate (unless the state where you do this has rules that render such "invalid" selections void, in which case it would count as no votes).
In states with more complex electronic voting machines, this scenario may not even be possible (e.g. you must make at most one selection and can't submit your ballot if it doesn't conform to certain rules governing validity).