The S-Pen itself will work, regardless of what ROM you are using. However, the S-Pen specific features won't work on non-TW ROMs. You won't have hover, pull out goes to launcher page, notification when the pen is out, and probably the leaving your pen behind notification would be broken on AOSP based ROMs as well. The usage of it though for writing and such will still be there, but it would just be like using a capacitive stylus on any other phone, you won't have all the other stuff Samsung added to make it very functional.