Yes, this is the standard setup for most people living abroad, and dual SIM phones make it painless. Keep your home SIM in one slot, set the local SIM as your data line, and configure the home line for calls and texts only with data roaming disabled. Your home number keeps receiving SMS, which is the critical part, since banks, government portals, and old accounts all send verification codes there. Receiving texts is free on most carriers worldwide; receiving calls abroad may cost, so check your home plan's roaming terms.
The main thing that catches people out is number expiry. Prepaid numbers die after a period of inactivity, and even postpaid accounts can be suspended if payment methods lapse.
If your phone is single SIM, options include swapping SIMs when you need a code (clumsy but workable) or moving the home number to an eSIM if both phone and carrier support it.