Yes, its actually very simple. Its the same process you would use to program a smartphone to be used as a key. The only "gotcha" would be, some of the keyfobs for model 3/y (same fob) are the older style that do not have passive entry.
That means that they dont work like phone as key, the button has to be pushed on them to use them. Newer style ones do support passive entry.
Learn about the Tesla Model 3 Key Fob. Find out where to purchase your key, replace the battery and how to pair your key to your Model 3.
www.tesla.com
Relevant part relating to what I am saying:
=========================
Does my Key Fob have Passive Entry?
Key fobs with the TESLA logo printed on the flat side have the passive locking and unlocking functionality. Key fobs with the MODEL 3 logo printed on the flat side cannot passively lock and unlock your vehicle.
=========================
TL ; DR -- yes it will work as long as the keyfob itself is functional. It may or may not have passive entry.