That's how 50 Shades of Grey happened. It was originally Twilight fan fiction.
I know in Japan there is more leeway with this sort of thing, and doujinshi using characters. Most companies consider fan works okay, but a lot of those use the money gained to keep making more, and have little profit. In America, it's a lot less open, you will probably get a cease and desist order, and if you keep going, then you will get sued.
