Interested to learn more about this as well.
It appears there are exchange controls in place, but generally, there are no restrictions for opening bank accounts for non-residents.
Supposedly, as a foreigner without a residency card, you will only be able to open a convertible currency account. Later, once you have established residency, you will have the opportunity to open a Dirham account. With a convertible account, you can deposit foreign currency from a foreign account, and it will be automatically exchanged into dirhams. Allegedly, you can send the money back to this foreign account without issue. However, the disadvantage is that you cannot make deposits in dirhams to this account from within Morocco, nor can people send you money from their Moroccan bank account. In comparison, with a Dirham account, you can receive foreign money and send money between bank accounts in Morocco.