I cannot speak for other devices but Motorola Nexus 6 will show you a warning that userdata would be destroyed. The warning is shown both on the shell and on the device's screen. See screenshots:
It is to be noted that the warning would show up only when OEM unlock setting is enabled under Developer options. If it is disabled and you attempt to re-lock the bootloader, you would get an error on shell and an instruction to enable that option.
It should be further noted that not all the devices which support flashing through fastboot protocol have their bootloader programmed smartly. An example: How to re-unlock bootloader for OnePlus One?
Furthermore, it is very much possible that your device's bootloader is programmed to go straight with a reset instead of showing a warning.
A bit more info. Google on Factory Images for Nexus Devices has noted:
Locking bootloader will wipe the data on some devices. After locking the bootloader, if you want to flash the device again, you must run fastboot oem unlock
again, which will wipe the data.
Google in the document Verifying Boot explains:
Changing device state
State changes are performed using the fastboot flashing [unlock | lock]
command. And to protect user data, all state transitions require a data wipe. Note the user must be asked for confirmation before data is deleted.
- The UNLOCKED to LOCKED transition is anticipated when a user buys a used development device. As a result of locking the device, the user should have confidence that it is in a state produced by the OEM.
- The LOCKED to UNLOCKED transition is expected in the case where a developer wishes to disable verification on the device.
(Emphasis mine)