Would it be illegal for the UK to negotiate a trade deal with the EU while still a member?
Or is it the signing of trade deals that is prohibited, and negotiation is permitted?
Illegal? Probably not. Remember, the initial plan was to invoke article 50, and spend two years on hammering out the withdrawal agreement and the "future relations". A trade deal between the UK and the EU falls under the future relations.
But the EU has made it clear it won't start negotiations about future relations before there is a withdrawal agreement. As of this writing, it's 70 days before the 2 years are up. There is no withdrawal agreement yet. Hence, at this moment, the EU will not negotiate a trade deal.
The UK could negotiate a trade deal, but other countries aren't really interested in putting resources into a negotiation that will probably take several years anyway at this stage. Until the UK has decided what its future relationship with the EU will be the parameters of any other trade deals are impossible to define, so any talks would be extremely preliminary at best.
It wouldn't be illegal for the UK to do, but it wouldn't be of much use either. The signing of such deals would be problematic at the moment because they would conflict with the treaties that established EU membership.
The EU decided that EU members cannot negotiate trade deals with third parties while they are EU members. Those rules did not go to much length when it comes to EU members who have negotiated and ratified a withdrawal agreement under Article 50, and either way the EU would not be a third party. EU members can and do negotiate matters affecting trade with their fellow members.