The prosecutor told public defender to tell client "If he needs to sign this plea bargain, because if he doesn't I am going to have him sentenced as a habitual offender"? Is it legal to be threatened into taking a plea bargain?
This is not a threat, rather he is disclosing to you what he plans to ask the judge if you go to trial. The judge could choose not to sentence you as a habitual. The judge could also decline to accept the plea agreement.