Yes. As long as you are still the employee of Company A, and on the payroll of company A, you can transfer to Company C or any other company that wants to hire you and sponsor you visa. I have processed this kind of H1B visas many times.