You can do this by switching the domain contoso.com from authoritative domain to internal relay domain in the accepted domains list in Exchange management console > organization configuration > hub transport > accepted domains.
For domains listed as authoritative Exchange assumes all the addresses in that domain are known inside Exchange but for domains listed as internal relay Exchange reroutes emails to addresses not known are routed out to the internet while emails to addresses that are known inside Exchange are delivered normally.