You do not need to have the ticket "scanned" (used) at the gate before you do the upgrade.
(You CAN do that, if you like, and its won't hurt the upgrade.)
The thing you need to know is that certain (MOST) "free" tickets cannot be upgraded (and never could be.)
It absolutely depends on where the "free" ticket came from.
Most times, tickets awarded as prizes and premiums for raffles and similar are
"complimentary" (comp) tickets, and they have no actual "value" (Disney gives them out at no charge) and, therefore, have no price value to upgrade "from."
More info on how to Upgrade can be found in the Tickets link in my signature.