Is it possible to create ASP.NET 4.0 "_layouts" pages in Sharepoint 2007 (WSS or MOSS)?
You'd have to reconfigure the application pool of your Web app to use .NET 4, but this is not supported. Even SharePoint 2010 is on .NET 3.5.
Although it's not officially supported, I believe the situation is similar to using .net 3.5 on the earlier versions of SharePoint 2007 - it works with a bunch of changes to web.config, as all newer versions of .net support running 2.0 code.
That said though, you should test with a simple page before you commit to anything, and you're out of luck if you need to get it past corporate infrastructure people.
@Tom Clarkson
Although it is true that you can make web.config changes to a MOSS site in order to get it to work with ASP.NET 3.5, I am not sure that is the case with .NET 4.
ASP.NET 4.0 uses a new version of the CLR, unlike versions 2.0 -> 3.5. 3.5 is really just a marketing term and should probably have been named 2.x.