Set two different lock setting on different triggers
You could use Android's Smart Lock feature for this, see e.g.:


Use Smart Lock in Android 5.0 and Never Unlock Your Phone at Home Again
How to use Trusted Devices in Android


If you have e.g. any Bluetooth device, you can tell your Android device it's "safe" as long as it can see it (so: no lock), but "not safe" otherwise (device gets locked). To have your device locked, you'd simply have to shutdown or disconnect the BT device (or have it out-of-reach; for Bluetooth-devices usually being away 10m is enough – even less with walls in between).

Smart Lock works natively with Android 5+ – and for earlier versions, there are fitting apps (e.g. Zwype Lock Screen, SkipLock, or using one of the more generic automation solutions to build your own: I e.g. use tasker with the Secure Settings plugin for this).