In the hotel, on the restaurant door there was a notice "Please be advised that long trousers must be worn in the evenings for the restaurant". (Note: the notice is non-gender specific and was, as usual, generally ignored by the women.)
I was too tired to argue on the first day, so meekly complied on the first evening. However, next day at breakfast when people wear more or less what they like, I hit them with a sarong. There were - no comments. I went in to the restaurant in the evening still wearing a sarong. Again, no reaction, although a couple of the management suits appeared to confer briefly while looking my way. I'd guess the rule was made to stop men turning up in their ugly shorts. (One guy was caught wearing shorts. He explained that he hadn't brought any long trousers with him. I didn't find out what happened.)
I wore sarongs exclusively for two glorious weeks, and even wore one on the flight home - incredibly comfortable, highly recommended. Back in England, I don't know what the two very big, flinty-eyed plain-clothes security men thought as I walked through passport control. I was wearing a blue polo shirt and an orange and blue sarong, and must have stood out in the drab crowd.
The local Tunisians asked, on four separate occasions, if I was Scottish. They were obviously aware that Scots wear a 'skirt', so I explained about the kilt.
The only negative comment was overheard in the hotel restaurant. A guy with an American accent (he may have been Canadian - they all sound the same to me

Most of the Tunisian girls wore jeans, as of course did most of the men (in temperatures in the high 80s F??? No way!! But then, they're probably used to those temperatures.)
So, if you are in Tunisia, wear a sarong. No-one seems to care, although one girl did have a fit of the giggles. She wouldn't have giggled if I'd been wearing jeans, just like she was

Charlie