Depends -- did the person selling it already type the code into STEAM ? If they did then No it will not work online as the code is tied to the very first account that it is installed on and is not transferable (And is it worth the small difference in cost to chance getting a game that will not work online ?)
People try to make you think that Steam is there to prevent Piracy but it's main purpose is to keep games from being sold USED and that is the main reason most companies continue to pay Steam to use their service even though the games are pirated within hours of release in most cases.
Also remember that Steam banning your account would mean the loss of all games you have on that account so trying to use an illegal copy could result in you losing every game you have purchased from them not just the one game so probably not worth taking a chance unless you do not plan to play anything but the single player portion of the game !!
That said --- If you buy it from a regular reputable retail outlet (ie. Gamestop, etc.) Then YES it will work fine with STEAM just is tied to your Steam account once you enter the code !
If you want the game I would buy it, the seller has good feedback and if you pay by Paypal and there is anything dodgy then you should be able to get a refund. I personally thought Crysis 2 was not a good game but many people enjoy it.