Dock is stopping me from unmounting a hard drive
[This answer cropped up earlier in the week for a totally different question, but it seems appropriate again here…]
I would be more inclined to prevent the volume from mounting in the first place, then it won't need to be ejected.
You can prevent it from mounting using fstab.
I wrote an earlier answer on using this, so I'll link to that rather than covering the same ground again. The question itself is entirely unrelated, but the answer contains step by step for fstab
Time Machine restore to new partition, different computer