Is there a way to safely eject a USB hard drive from the lock screen?
AFAIK there is no save way to eject an external drive from the lock screen.

You have several options though:


Purchase and install Mountain and enable "Unmount external volumes on sleep". The feature still seems to be experimental.
Create a LaunchDaemon which ejects your external drive(s) gracefully at say 5am. Here is an example of a bash script to start with:

#!/bin/sh
/usr/sbin/diskutil list | grep -e 'disk[1-9]s.*' | sed 's/.*\(disk[0-9].*\)/\1/' | xargs -I{}
/usr/sbin/diskutil unmount {}


If you don't want to write a LaunchDaemon, Sleepwatcher should support your efforts.
Unmount all external volumes before setting your Mac(s) to sleep.