I would not call "in" a preposition there. Many prepositions, when they appear without an object, act as adverbs.
I would say that "working" is a gerund (noun) that is the object of the preposition "for". "In" then becomes an adverb modifying "working".
This would change if the phrase was "for working in a factory". In that case, "in" is a preposition and the prepositional phrase is adverbial.