Not really, for two reasons:
1- Gravity works fine
The idea is to defeat attackers when they are the most vulnerable. Which is when they try to storm the castle. Why set up complicated machinery if you can simply drop rocks, boiling water or oil from a murder hole?
2- The foundation couldn't handle it
A catapult has a severe impact on the place where they stand. The force used to hurl a rock has to go somewhere. That's the reason why an onager was called an onager: it kicked like a mule.
First of all, there was rarely enough room on a wall to place such a device. Second, supposing you would be able to place one on a turret or large enough space: the "back blast" (for lack of a better word) could destroy the place it stood.
If you placed it behind the wall on ground level, you would have severe problems aiming the thing. Indirect fire wasn't invented yet.
There were some cities and castles that could accommodate catapults on their ramparts, for example Constantinople. But they were the exception, not the rule.