It probably CAN be done, but whether it's a good idea or not is another issue. I have three oscars, and my big boy Bruno has been living alone in a non-standard 55 (width is 18in rather than 12) and even at barely 10 inches he's starting to look like a big fish in a little tank. For his sake and mine he's going to have to be upgraded this summer.
Besides the obvious size issues, oscars are really, really messy. This is the main reason 55gal is the recommended minimum. They chew up their food, spit it out, and chew it up some more. They create tons and tons of waste and it's a lot more work to keep up with the water quality, even in a larger tank, than it is with the majority of other fish. I was totally unprepared for mess oscars make when I got my first one.
A 40gal will be fine short term, but between his size and the number of water changes you're going to have to do to keep him healthy you'd probably end up wanting to upgrade within the year. They're fantastic fish, I love all of mine soooo much, but they're really big, really messy fish.