First off, he can not take you to court at this moment in time. A court will not decide the custody of an unborn child.
You can move back to Idaho and to be honest I would suggest to do it now. To be able to file for custody you have to meet a residency requirements of the state. If you move now, you are clocking days before the birth of the child.
Now, when the child is born you determine what last name goes on the birth certificate. You can list your married name or you can choose your maiden name or you could choose the last name of the father. That decision is yours.
Since you are still legally married, there could be an assumption on the birth certificate that your husband is the father. You will need to establish that he isn't the father to clear his name. That is allowed on most paper work in the hospital. In most states, you can not list a father's name unless you are married, without the consent of the father. He has to sign a waiver accepting paternity. If he is not there - he can not sign the waiver.
For the father to go after custody/visitation he would have to establish paternity and then go for it. I would suggest that you file for it first, hopefully you would have meet the residency requirements at this time and you would file in Idaho. That would establish Idaho with jurisdiction and all hearings would have to be through that state until it is changed. It is rare that a court would remove a newborn from its mother. he would have to prove you unfit before he could do that.
Now the other side of the coin. If you wait to have the child in Montana and he establishes paternity, you would have to have his permission (which he apparently doesn't want to grant) or the permission of the court to relocate.
Which sounds easiest?