How to implement OTP verification?
Answering your questions respectively:

1) You are able to implement OTP using firebase Phone Number Authentication. The related link is here https://firebase.google.com/docs/auth/android/phone-auth

2) Two-factor can be implemented by using a normal login setup in addition to a phone number Authentication. Firebase can also perform login setup for you at https://firebase.google.com/docs/auth/android/password-auth

3) You may google search for SMS OTP Service Providers and you would find ample of messaging companies offering Phone Verification APIs. Here are some of the top listed OTP service providers; 2Factor, Twilio, Plivo, Nexmo, Sinch, Zang.

4) The techniques vary across providers. With AES being more secure while putting a large security load on the system compared to a scrambled 6 digit SMS-code provided.

5) Both methods I have listed in (4) uses a random 6 digit pin with AES encrypting the code additional times with its algorithm. This might be what you are looking for: https://codepen.io/corenominal/pen/rxOmMJ