Well, you could use a helical broach, but I suspect it’s not the sort of tool you have lying about on the off chance.
Could use EDM, but again not the sort of machine most people have.
It would be possible to do it on the lathe, but it would be a funny looking tool to get the right clearances. More of a shaping action. So it could be done on a shaper or slotter with the right feed mechanism.
It could probably be done on a manual mill if the nut was split and done in two halves.
However, the nut looks like plastic or anodised aluminium?
If plastic then the thread could be made by a heated screw, or a simple home made broach.
But, since this was presumably a repair job, and was done in an afternoon, I prefer the ‘slap some goo around the screw and make a moulding’ approach. Could use resin or one of ‘liquid metals’ for better strength.
Whatever way, it’s out of my league.
Regards,
Andrew