But it isn't semantically correct, though: it's not a meaningful sentence. If you use it you would probably mean to give an action of your earnest, but it still sounds awful as a sentence.
Also, sounding strange is actually the basis for the evolution of language; people tend to reject 'strange-sounding' words and phrases, and slowly those become unsemantic, even if they're grammatically correct. The important thing is being understood, so being semantic is as important as being grammatical.
It is meaningful, though. You even demonstrated in your second sentence how it could be used.
Duolingo is not an English teacher judging your eloquence, Duolingo accepts sentences objectively as translations of other sentences. If something is grammatically correct and not nonsensical, it should be accepted.
Why should you, though? It's the most accurate translation as far as I can see. It doesn't mean 'I'm a serious person.' 'I am in earnest' is unambiguous. I'm getting so bored with having to avoid correct translations because Duolingo gets it wrong. I can understand it when the course is new and people can't be expected to think of every possible variation, but to reject the repeated reports when everyone keeps telling them they've got it wrong is just foolish.
It might help to know that the English cognate "earnest" used to be a noun and a verb as well as an adjective. An "earnest" - now more commonly called "earnest money" - would be an advance deposit, like for an apartment that you're applying for. English lost the usage of "earnest" as a noun, but German kept it.
I wrote: that is serious for me, and was marked wrong. The "correct" answer was given as: that is serious to me. This is not exactly perfect English. An English speaker would be much more likely to say serious for me, rather than to me. A small detail, but you should change this.
Is there any difference between ''Das ist mein Ernst'' and ''Ich bin Ernst''? Is one describing your general personality whereas the other is describing your attitude towards one single incident?
I mean something like ''Mir ist gut'' and ''Ich bin gut'' is totally distinct as in I am feeling good and I am a good man.
But note that you must not capitalize "ernst" in the second alternative.
"Das ist mein Ernst" (using the noun "Ernst" (= "seriousness")) means "I am serious" in the sense that I assert that what I have said is to be taken seriously.
"Ich bin ernst" (using the adjective "ernst" (= "serious") describes me as a serious person.
Btw., there is also a German first name "Ernst", so if you capitalize "Ernst" in the second alternative, it would be "My name is Ernst".
I have a question: why is "das ist mir Ernst" not correct? like saying "that is important to me"? If I consult Duden they also have an example that says "Es ist mir [völliger] Ernst", and this also sounds more natural to me (more similar to for example "es ist mir langweilig").
this also sounds more natural
But it isn't. "Das ist mein Ernst" is definitely the more common way to express it. I (native German) had never heard before about the version you propose and had to look it up in the Duden.
more similar to for example "es ist mir langweilig"
That's not a valid argument. "Ernst" is a noun, whereas "langweilig" is an adjective. So you can't expect them to use the same construction.
"Das ist mein Ernst" translates to "I am serious".
"This is serious" has a completely different meaning (it would be something like "Das ist ernst" in German; note when "ernst" is capitalized and when not!).
Different languages use different constructions. You can't just translate word by word.
"Ernst" (capitalized) is a noun and means "earnest" or "sternness". So "Das ist mein Ernst" is literally "That is my earnest", and it means "I'm serious".