You would have to log in to the Yahoo account in order to change the phone number the message is sent to. I suggest calling your old number and seeing if the person who has it now would be willing to help you and forward the message on to you.
Your alternative is to choose the option instead of an email or text msg to answer the security questions on the account. Here is Yahoo's procedure:
Yahoo Password recovery
Go to the login page and select "Forgot Password". It will take you through the password recovery process.
You will need to go through 1 of 3 processes:
1) provide your alternate email address
2) If you entered your mobile number in setting up your account, choose that opiton to receive a text with instructions
3) Failing either of the first two methods, the third is to answer the security questions you set up when you enrolled the account.
Unfortunately, if you don't have the email address, didn't register a mobile phone or no longer have that number, and are unable to answer the security questions you will not be able to recover access to the account.