Those who purchased the Pixel 2 device directly from Google Store where unable to unlock the bootloader. The unlock slider is disabled.
As per the google pixel issue tracker the issue has been fixed. To enable the unlock toggle all we need to do is Factory reset the device and during the initial setup Pixel 2 device needs to be connected with internet. Once it is done unlock toggle will be enabled.