Although Morocco is more liberal than many other Muslim nations you do need to be careful when purchasing or consuming alcohol. Morocco does allow the consumption of alcohol and you can buy beer, wine and spirits in licensed hotels, bars and supermarkets. In supermarkets there will often be a separate alcohol room which is out of sight. If you attempt to purchase alcohol outside of one of these licensed areas then you may find yourself in trouble with the police.
While in Marrakesh, if you want to have a drink with a meal, it is best to check with the restaurant if they serve alcohol before you sit down. You should also ask if they are happy for you to sit anywhere whilst drinking or if they would prefer you to sit at a corner table out of sight. While you are up in the mountains trekking, things tend to be a bit more relaxed than in the city. However, it is best to show some consideration for your cook and porters by checking with your guide before you crack open the whisky.