To do what you ask can only be accomplished in part. iCloud is more of a backup service, not a storage solution. However, in the case of photos is can help make space on your device by only keeping lower quality versions on your phone while storing full quality in iCloud. Read about optimization specifically with reference to - Set up and use iCloud Photos - Apple Support
--> Save space on your device
iCloud Photos keeps all your photos and videos in their original, high-resolution version. You can save space on your device when you turn on Optimize Storage.
If you really wish to not have some photos at all on on your device, transfer them to a computer (which was not exactly what you were asking about).