5th dnd – Can you prepare an action to attack with a range the natural weapon of a monster (part of his body)?

In my current group, OOTA, my party has fought against a rocktopus. They attacked them from the ceiling out of range of melee attacks.

Is it possible for players to prepare an attack with the trigger "when one of the tentacles attack I will hit him"?

Normally, I would say no. If your target attacks you with a longer range weapon and is out of range, it should not be possible to hit it with your prepared action. But the melee weapon (the tentacle) is part of the rocktopus and I'm not sure how to handle this situation.