Souk Market Stall on Busy street in the centre of MarrakechThere are certain rules for any solo travellers and it doesnt really matter where you are. 

Be careful.
Be aware of your surroundings.
Always carry your hotel address on you.
Keep cash in your pocket and in your purse / wallet.
Walk in well lit streets.
Do research in advance.
Know where you are going.
Be streetwise.

There is no difference to travelling alone in Marrakech say than there is in Mumbai, New York, Katmandu or Singapore.  You need to be streetwise where-ever you go. And you should always do research in advance.  Chat to your hosts or the concierge at your hotels.  Ask if it is safe to walk, or if you should get a taxi.  Ask if it is ok to be on your own?  And then make decisions.

Marrakech is a busy, bustling and sometimes chaotic town. It is what makes it so interesting – the narrow alleys, the bustling markets, the traffic and the many people.  It is also an incredibly friendly place.  Moroccans in Marrakech know that they need tourists and understand how important tourism is to the economy.  As a solo traveller, they want to keep you safe.  They only want good stories.  They will welcome you and look after you.

But you still need to be streetwise.  Dont trust everyone you meet, keep your money safe, and only ask questions from people who you think are there to help. If you are a woman alone and somebody is harassing you, move away as quickly as you can.  Dont go into quiet streets on your own and ignore cat calling. Hopefully there isnt any, but be aware.  If you are nervous, get a guide for the day.  In fact, when exploring Marrakech it is recommended anyway that you get a guide to help you negotiate the streets but also to ensure you see and find all the fabulous places.

You can visit palaces and mosques on your own. Maybe use a guidebook, or read up in advance so you know what you are looking at.  Always keep cash in small denominations, both for entrance fees and for tipping.  And remember, keep cash in two places, just in case you lose your wallet or it gets stolen. Its unlikely but in any big place, things can happen.  

There are a lot of solo travellers in Morocco, usually young and adventurous.  If you are travelling on your own, you will likely meet up and make new friends quickly. There are many fabulous restaurants and coffee shops where you will feel totally comfortable alone, and always try the street cafes too.  When you walk around the old town or Medina, have fun, dont feel too anxious about where you are, but have a landmark in your mind so you dont get lost.  And dress appropriately.  For women, even in peak summer, dress modestly.  And if you are going to enter a mosque or similar, you should read up on the ground rules regarding dress.  You never want to offend anyone.