Trap the soul forces a creature's life force (and its material body) into a gem.
It seems there's no description in the spell says if it would not work with an undead. So I assume it would just work for any undead and would trap their material body (with or without a soul).
But since a lich has already trapped its life force in a phylactery (so it does have life force that can be trapped by this spell), what would happen if it is affected by Trap the Soul? Would its life force be dragged from its phylactery into the gem?
An integral part of becoming a lich is creating a magic phylactery in which the character stores its life force.