How to apologize after unwanted sarcastic comment while giving feedback?
You can't, at least not in the way you describe as wanting to do this in your question, or with the message you propose sending. Whatever that message is, it's not meeting the minimum requirements for an apology as desribed on this wikihow page:
A good apology will communicate three things: regret, responsibility, and remedy.
A good apology takes responsibility, so it requires you take responsibility for the fact that you did not know the meaning of the words 'nice attempt'. If you want to communicate that you made a mistake in using these words, you're going to have to admit that you made a mistake in using these words.
The message you're thinking of sending will not communicate that you made a mistake. If I would get such a message, at best I might see it as nothing but a formality, someone thinking I need encouragement to do better after my 'nice attempt'.
Your last sentence though would make me think you're just trying to add insult to injury: first you sarcastically bash a thesis, then you say this person is your inspiration? That's too much like more sarcasm at this point, the difference between the two is just too stark to take that second message seriously, let alone see it as an attempt at reconciliation.
How can I communicate about the misunderstanding and bad writing so that it's clear it wasn't intended to be sarcastic?
If you want to be clear that this was a misunderstanding, you're going to have to directly admit that there was a misunderstanding in the first place. Admit and explicitly state that you did not know 'nice attempt' has a sarcastic meaning, and that you weren't using the expression sarcastically. Only after that, you could possibly go on to explain that you really liked the thesis if you want to, without being seen as just adding more sarcasm to the pile.
English is my second language. If I write something in English, and the word has a different meaning, people either correct me, or I correct myself if I notice people are starting to misunderstand me. It works best to admit that you're just using words without having been aware of their 'second', less literal, meaning. After that, you can continue the conversation with the knowledge that now, both sides know what is being talked about.
The only stupid thing would be to not own up to this mistake. No one has ever openly accused me of being stupid for getting a word wrong, so don't fret over that.