No its NOT legal to insure a car you no longer own. It should be flagged up on the insurance data base. They dont want it riding past and showing as insured when it really isnt.
On the other hand ive done it a few times and never had any come back. The last policy I left dormant they offered me ?8 for four or five months left by the time they had added there admin charge.