Do not expect to receive severance unless you stay till the very last day Company A wants you there.

Company B COULD fire you because there is no law that says they can't. However, why would they? Why do they care if you're collecting a paycheck from someone else while you work for them, as long as the someone else isn't a competitor? It's much more likely that Company A would fire you so that they don't have to pay you severance. Or, for that matter, the paycheck for doing nothing.

It would not be illegal; there's no legal reason you can't do as you propose. But there's also no legal guarantee that it will work out the way you anticipate, either.