You can search for referenced photos with a smart album:
- File > New smart album
- Set the rule to "Photo is Referenced".
- Then select all photos in this new smart album with the key combination ⌘A and use the command "File > Consolidate".
This will copy the referenced images into your Photos Library.
The procedure is described here: Check the status of your library in Photos for macOS - Apple Support
You may also want to check the Photos > Preferences > General.
The preference "Importing" should be set to "Copy items into the Photos Library". If this option is off, Photos does not copy the photos into the library, and then you cannot use these photos for iCloud Photos.