In Mac photo application , select few photos https://support.apple.com/en-in/guide/photos/pht40b0be510/4.0/mac/10.14
and export them .
Export photos
Shift-Command-E
A folder will be directly created in iCloud Drive having the number of photos you selected .
Some users like to save photos in the iCloud Drive , but this will increase the storage of iCloud Drive as you might have some documents , files .. also when desktops and documents box and iCloud is turned as on https://support.apple.com/en-in/guide/mac-help/mchle5a61431/10.14/mac/10.14
So what you inquired keeping all photos in iCloud Drive is not recommended , for that you need to set up iCloud photo library https://support.apple.com/en-in/HT204264
And its preferences https://support.apple.com/en-in/guide/photos/pht5156cc968/4.0/mac/10.14
and you wish the photos to be transferred to the connected external hard drive see these https://support.apple.com/en-in/guide/photos/pht6d60d10f/mac
In finder > Go > home > your user name > pictures either drag and drop PhotosLibrary.photoslibrary or masters folder to an external hard drive .
Note : masters folder is in Mac OS mojave and the name is changed to originals in Mac OS catalina 10.15
If your Mac and an iPhone are signed in with same Apple ID and password , and you create a folder in iCloud Drive
And right click on the column the photos can be imported from iPhone to Mac ( it is greyed because right not the device are not synced , just to explain ) and this will also increase the space in Mac , but you have not clarified in your post that devices are syncing .