I would think a custom spline broach would do the job.
They can be ordered in standard or custom shapes, but are not cheap.
Spline broaches can be made to order in many complex shapes.
Spline broaches are used to make flutes inside faucet handles, fluted drive shaft couplers, internal gears, etc.
Spiral spline broaches are used to create rifling in gun barrels.
?
For more info...
Google spline broach.
?
See:
https://broachingmach.com/spline-broaching-the-complete-guide/
?
Richard