Unless your H-1B petition for company B is still valid, company B needs to submit a new H-1B petition on your behalf and apply for a change of status at the same time. Company A does not need to know about this. If you use "premium processing", the H-1B petition and change of status can be approved in 15 days or less.
You may apply for change of status to H1B, it will in essence be a new application.
You will not be able to utilize the old H1B at this time since it has expired. Consider premium processing.
Hopefully your company has a lawyer to represent you or retain one.