Tip 1: Don't wait to the last minute to lie.
From the start of the game you should be deciding on your false identity based on the role list, your own role and any information given to you as the game progresses. If you wait till you're on the stand to make something up odds are it won't be very convincing. Look at your role card and what an investigator would see you as. Try to make up a fake LW to use incase an invest sees you. If your corresponding town role doesn't normally have a living will, write some extravagant roleplaying in your lw to use instead. I've false claimed BG a couple of times and used this as my defense on the stand:
"I'm BG and here is my LW"
"Many have stood their ground and faced the darkness when it comes for them."
"Fewer come for the darkness and force it to face them."
"I like to roleplay my LW when I play a role without any information to convey."
Simply appearing that you hadn't thought up your defense at the last second is enough to place doubt that you're guilty.
Tip 2: Obscurity is a crutch, not an ally
Most new mafia players try to lay low and only lie once they're caught. Lies work best if you start telling them before people think you are suspicious. You need to develop a reputation with the town so that when you reveal your fake role, they are more likely to accept it. You should be working together with your fellow maf to give each other alibis. Just be careful to phrase it in a way to not alert a spy.
Some examples: the mafia are players 3, 4 and 5.
As consig in maf chat say "5 is sher", this communicates to your fellow maf that you intend false claim a fellow maf as sher so they can prepare a LW. In your LW you can include true info about town, but also give a sher alibi to a fellow maf.
"Judging by 3's day chat I think hes a doc, should we kill him?"
In maf chat say "jail 4 tomorrow" where you are 4. If your kidnapper isn't an idiot he will pretend to jail 4 and the next day you can claim you were jailed. If you were GF and there was a maf kill that acts as a weak alibi. If the kidnapper dies and includes you among other town in his LW that acts as a weak alibi.
Tip 3: Don't use common lies.
The most common false claims are sher, bg, doc and cit. These are the most common because they take no effort to back up. Because they are the most common, people are less likely to believe you unless you bring something extra to the table. You don't need a consig to claim invest. If you can figure out someones role, include that in your LW along side info of dead people. As long as someone living can confirm you're telling the truth you've got evidence to your innocence. If you're really got no outside info to be able to claim det,lookout or invest, try claiming a rare role. Claim coroner and fill your LW with your astonishment that janitor hasn't cleaned anyone yet. Claim spy and make a fake LW of where maf went each night. Claim Mason Leader and include a LW of people you know aren't cits.
Tip 4: Try to keep your accusers alive.
If you've convinced town you're innocent, don't try to lynch your accuser. Town already doesn't trust him and expects mafia to want a kill a town that knows their identity, if he dies and is revealed as a town role, you'll go right back up on the stand. Claim you accuser is a jester or an exec. Tell town its not worth lynching an exec. If it gets to the point that a neut benign is killed, be the first to accuse your accuser of not actually being an exec.
Tip 5: Talk to your mayor every day.
Not just your mayor but any confirmed town. Whenever a confirmed town appears, demand that everyone PMs him their roles. Don't be afraid of making a confirmed town more powerful. He likely isn't prepared for the extra responsibility you just thrust upon him. This alone will likely put you in the moderately trusted category. Supply him with information every day. If you're an investigative role, back up your friends claims or implicate a town. If you're not just ask him "Xs voting record is suspicious, did he give you verifiable info?" As long as the mafia gave him some false claim there will likely be someone who didn't which draws attention away from you.
Tip 6: Speak with authority, but also with common sense
This goes back to establishing a reputation. You can add seemingly good information to day chat without actually helping town.
"4 claims hes was attacked and healed and there was no maf kill last night. He can still be sk but he is almost certainly not maf"
{6 starts a random lynch and 7 & 8 join in} "6 might be a troll but people that join in lynch trains are generally evil. 7 & 8 wanted # to be lynched but they didn't want to be seen as the initiators"
"don't waste a lynch, let jailor jail" -extra good if you've got a kidnapper
"make sure you include in your LW who you roleblock, sk kills roleblockers"
Tip 7: When shit hits the fan, throw a friend under the bus
Merely guiltying a fellow mafia member isn't enough to keep suspicion from being drawn to you. If you think hes caught and there's no way to save him you need to make sure you click that lynch button. If everyone votes guilty on a maf the next thing people are going to look for is who didn't vote to lynch him. If he gives a convincing argument you can still back out and vote inno.
If you are in the situation where you're caught, don't hold it against your fellow mafia members if they vote to lynch you.
Tip 8: Be who you are pretending to be.
I once heard someone claim that an SK was more powerful than the GF because the SK didn't have to worry about being found out by voting patterns. You don't either; your mafia allies are not confirmed town to you, do not treat them as such. This applies to voting, lynching and accusing or defending. If you didn't vote to lynch someone a sheriff claimed was maf you better have a good reason for it.
Of course, locking in a win is an exception to this but by that point you no longer need to worry about lying your ass off.