How can I create a membership number?
I'm not sure whether it would be any use to you but there is a CiviCRM Core  Extension called "Custom Membership ID" by Grant Traynor which is at the following link Custom Membership ID