The SIM can not known it's phone number.
Just if someone, or on SIM production, write the phone number on a special memory store on the SIM
(and can be added if not exist or changed later from some phone)
Probably an AT command exist for read that area, or some phones how read and write that...