How many do you need? And what other tools do you have? A CNC mill isn't much help for this. A lathe could be used to emulate a shaper, if the number of splines matches a sub-multiple of the number of teeth on the bull gear, but it would be tedious.
The way which I would make one or two, or a few is with an index head on a shaper, since the length is small relative to the diameter.
Does the number of splines matter? What about the shape? Your image looks like square splines, but the most common ones are about the shape of gear teeth. You might even be able to find internal tooth gears.
In addition to the mill and lathe, I have a relatively substantial drill press, but no shaper.
The actual number of splines is not important, nor is the precise profile of the splines. The purpose of this part is as an internal ratchet, used for a gear shifter on a bicycle. The spline profiles must be symmetrical as there are two pawls, one for each shifting direction (the pawls are disengaged at rest).
I am intrigued by your suggestion of using a lathe, how might this work exactly?
I feel quite stupid that this never occured to me. I had come across drive shaft coupling splines, but they tended to have too few splines for my purposes.
I just thought of an even better source for your internally-splined hub: the friction disc of an automobile clutch has just the part you need. You should be able to pick up an old one fro free from a local auto mechanic.
The small ones tend to be too expensive -- even so, I did get one eventually. :-)
Mount it in the lathe -- either in a 3-jaw chuck, or a 4-jaw chuck and take the time to center it well. (And you may wish to use the lathe to bore it to a nice concentric and smooth ID.)
Then -- take the boring bar for the lathe (one of the old ones which accepts HSS lathe bits ground to shape for boring), and grind a new bit for it -- with the tip as wide as the grooves in your splines, and with whatever shape you want. Mount it so the profile is end-on to your workpiece.
Next, turn off the power to the lathe, open the headstock cover (if you have back gears), pull the pin but don't engage the back gears, and clamp on a makeshift indexer which fits into the teeth on the bull gear. Use this to lock the spindle so it won't turn.
Crank the cross-slide so the tip of the tool is just barely touching the ID of the workpiece, and using the carriage handwheel, crank it towards the headstock, drawing the HSS tool along the length of the ID, cutting a shallow groove. Withdraw it, and crank the cross-slide out about 0.001" or so, and repeat (Aluminum would probably tolerate more, steel probably not. Keep repeating this until the groove is the depth which you want.
Then crank the cross-slide back in to where it was before, withdraw the indexer which is restraining the bull gear, and rotate one or two teeth (depending on the width of your spline grooves and spacing), and re-lock with the indexer. (Best if you make it so it can be returned to precisely the same place each time.) Now, cut another spline, just like the first one.
Keep repeating until you have the full collection of splines made. They will be some sub-multiple of the number of teeth on the back gear -- divided by two or three, or possibly even four for a coarse spline.
Hmm ... how about the spline in the clutch hub on a car? Some of them are square splines, fairly coarse, but others (e.g. the British MGB) have a fairly fine triangular toothed spline. The trick is extracting it from a dead clutch plate, and machining the OD to fit your needs.