Can I put my Photos library on an external hard drive also used for Time Machine?

You can avoid this problem by making two partitions on one drive - one for Photos, the other for Time Machine.

The safest way to do this would be to temporarily move your Photos Library to another drive first, shrink the existing Time Machine prtition, then add a new partition for Photos & move back again.