Two main ways.
If the game has some kind of teleport block you arrange them so when the level would have normally ended you get thrown back to the start (and obviously that continues when you eventually get back). This you can do with a simple editor if you have one for your game of choice. You may not need a teleport block either if you can force them back some other way -- think Sonic with one of those tubes like in Chemical plant zone but put one at the end, an impassable wall and then send the player back to the start with one or a series of them, possibly with a skill test somewhere in the middle to prevent them from sitting there for 15 seconds and breaking flow. Thinking NES mario again then set up a warp zone which warps you to the level number you just did (or a carbon copy elsewhere and then back again to the original if that is going to be a problem).
If timers are going to be a problem then you can hopefully find a cheat which freezes the timer, or stops it from killing you if you go over.
What any enemies or breakable objects will do will vary from game to game.
That is the crude way, though the end result will hopefully still be some kind of (effectively) endless game which may be enough for a proof of concept .
The less crude way is to figure out enough of the game and encode the above sort of thing, or make an actual endless stream (possibly even slightly randomised), right into the game itself. This will require some more skills though (likely some assembly skills which is usually considered the end boss of learning ROM hacking). If there is an existing editor (or you can make sense of any level format documentation) then that is a 5 minute learning curve as you get to grips with the level editor program. Learning enough to figure out a level format is not so bad. Learning enough to pull a game apart and sort all the problems that might arise (including maybe making a 15 second segment go endlessly) is harder, this is what will make the most polished hacks though (the teleport stuff is probably going to feel much like the dreaded invisible wall to many).
The latter bit there is not to say you can't possibly do exactly what you want with a level editor though.
Speaking of bosses then there is a type of hack called boss rush, which is pretty much what the name implies, and from a hacking perspective will likely play out much like what you want.
Finally the really crude crazy cowboy method.
Get keyboard macro program
Get keyboard macro program to either load a savestate every ? seconds or get it to read the emulator's memory and if it detects something like the end of a level then load a savestate (possibly even another in a sequence if you want to chain so many levels or mini challenges together).
Smile as you have technically violated one of Sony's patents http://kotaku.com/sony-patent-aims-to-add-new-challenges-to-emulated-clas-1493798231