The short answer is that teams can’t because the league approves all contracts and would not approve a contract that would result in a team going over the Cap. If a team were to go over the Cap because of the acceleration of unaccounted-for bonus pro-rations due to the trade or release of a player, the CBA mandates that the team has 7 days to come into Cap compliance. That would mean that the team would have to find a way – likely via the restructure or release of another player – to come into Cap compliance.
There have been a couple of instances where teams were discovered to have agreed to payments to players that circumvented the Salary Cap. The Pittsburgh Steelers and San Francisco 49ers were penalized draft picks and fined for agreeing to undisclosed, non-contract payments to players.