If you change your Apple ID password all iCloud operations are immediately suspended on all devices until the new password is typed in. So that would mean you cannot access your remote iMac via Back to My Mac.
However, here is a possible solution:
When you use two-factor authentication, you don't need to update your passwords on all your devices when your password is changed (it says so right at the bottom of
this article).
So, if you enable two-factor authentication and
then change your password, you should be okay.
Possible problem:
If you are currently using two-step verification (which is different from two-factor authentication - if you're not familiar with the differences
this article explains it well) then upgrading to two-factor authentication requires turning off two-step verification, and when that is done you have to type your password in on all your devices again - a possible problem.
However, your password hasn't changed. So the services like Back to My Mac should still operate even whilst password entry is being requested. If you had changed your password, the services would cease.
TL;DR: if you're currently using no iCloud multi-step security then upgrade to two-factor authentication before changing your password and you'll be fine.
If you're currently using two-step verification, proceed with caution but it should be okay.