A heat pump still needs ventilation and I’d recommend just as much as for a condenser dryer because, it’s removing the moisture that’s going to be the same amount you’d presume from the laundry and that moisture has to go somewhere. A lot will be caught of course but there’s always going to be an amount that goes into the surrounding atmosphere.
So as Dave very rightly point out, you can do this but you can’t use either in a closed cupboard as I doubt you’d get enough ventilation for that moisture to dissipate, the danger being of course you end up with condensation problems that could cause mould etc which you don’t want.
K.