Yes, the okey joker can substitute for any tile in either a run or a set.

In a run it fills a missing consecutive number of the correct colour, such as red 4, okey, red 6 standing for the red 5. In a set it stands in for a missing colour, such as an okey completing three different-coloured 7s. This flexibility is why the joker is the most valuable tile in the game. Just remember that finishing your hand by discarding the okey earns double the normal score.