Is it safe and legal to tape cable with a damaged sheath?
You would have to inspect the individual wires inside that outer sheathing.

The black, red, and white insulations should be 100% intact and not nicked/torn in any way or else you run the risk of serious problems.

Whether or not this "fix" is acceptable per code in your area would be determined by the code in your area so when in doubt contact your county/city engineer and they will make sure you do it right.