If you know the PIN code, you simply unlock the phone and then go to menu>settings>security and set the screen lock setting to your preference. (Depending on the version of Android you are running, the menu choices might be slightly different.)
If you forgot the PIN code, after several failed attempts, you will be prompted for the password for the gmail account that the phone is registered to. Please note that the phone must be connected to a data source for this to work -- either mobile data or wifi. If you don't have data enabled, then the only option is to perform a factory reset and clear your phone.