The play described below is provided for your review and discussion. The rulings given are based on NFHS rules. NCAA rulings may be different.
A-1 is fouled with 5.5 seconds remaining in the game and Team B leading by two points. After A-1 makes his first free throw, A-3 is replaced by A-6. After A-1 makes his second free throw. Team B is granted a timeout. At this point, A-3 reports to the table to replace A-6.
Handle the situation.
Because no time has run off the game clock, A-3 is not permitted to return to the game. It does not matter that either team has taken a timeout.
While this situation does not occur often, it usually occurs late in a close game when teams may be switching offensive and defensive players. It is good practice at these times to note who leaves the game so that you may be aware of attempts to return players to the game in violation of this rule.
(References: Rule 3-3-4)
Have you seen an unusual play? Let all officials benefit from it by sending it to Play of the Day

What if there is a tech on B during the dead ball period. Can A3 then return to shoot the tech?
Correct. We have to be aware that A-3 cannot come in until the clock had started.
Thanks!