Can Smeargle sketch moves but pass them to Pokemon that cant learn them legally by using the breeding system?
No, Smeargle follows the same rules for breeding as everything else, so it can only be used to pass moves that are on the child's egg move list. This is a specific list of moves for each species that are the only moves they can learn by breeding, and any other moves the parents know won't be passed down (empty move slots will be filled by the child's default level 1 moves instead).
For example, here is is a list of the egg moves for Yungoos, who is in the Field egg group like Smeargle. The moves are Revenge, Last Resort, Fire Fang, Ice Fang, and Thunder Fang - it will hatch knowing any of those moves if Smeargle (or its mother) knows them, but it will not inherit any of their other moves.