You can do it with a custom grip OR a grip script. If it is a one off effect only for a one base class type of weapon it would probably be faster to make it a custom grip.
If you wanted it to be re-useable logic across multiple base classes then a grip script would be better.
You can also live change the type of grip, IE: when it starts penetrating turn it into a custom grip and run the pull out logic, when it is fully free again then go back to another grip type, ect.