Can I play Sophocles and discard two cards if there are no cards left in my deck?
No, you cannot. Discarding the two cards is a cost not the effect, and you cannot play Trainer cards for no effect.
Source: TPCi Rules Team (2019-03-21)