Is it possible for me to leave my HDB flat to a non next-of-kin?

You may wish to consider writing a will to ensure that the ownership of the HDB flat is distributed according to your wishes. In the absence of a will, your flat and other assets will be distributed in accordance with the Intestate Succession Act (ISA).
However, you should pay special attention to the ownership type of the HDB. If the flat is under joint ownership, the deceased shares will transfer to the remaining joint owners and cannot be willed away. Only HDB's that are solely owned, or owned via tenancy-in-common, can will away their share of the property according to their wishes. It is strongly advised that a lawyer is consulted for matters relating to writing your will.
You may read more information about retaining a flat following life events at HDB's website.