Lloyd is hiding in a garbage can on the roof of Merrysville Elementary (Twinkle Elementary School). You need to get a bottle rocket from the Little Sweet (Sweet little) Factory, to the south, to entice him to come out. Buy him a boomerang, then use the Onyx Hook to go to Magicant so you can upgrade his armor. Go through Magicant again, leveling him up, and then you can proceed to the Duncan Factory.
A second Franklin Badge can be found here, which will be extremely handy near the end of the game.
Your goal here is to find a large rocket. After you CHECK it, Lloyd will aim it at the boulder blocking the way to Union Station, which is your next destination. Follow those railroad tracks!