If your phone uses a SIM card, you can set a lock on the card so it can't be used by anyone who doesn't know the lock code. This isn't anything new, and it stays tied to your SIM card -- not your phone. It's easy to lock or unlock your SIM card on Android. Go into the settings by pressing menu > settings > Location & security > Set up SIM card lock. You can toggle the setting on and off by simply checking the box.

Fair warning: you may have to get the default SIM card pin from your carrier, and too many tries can and will bork your SIM.