Would-be marines have to get through a rigorous examination.
I infer that "Would-be marines" are those who want to become marines in the future. So, my question is whether there is a certain line which helps to differ one meaning from the other? As it looks quite blur to me. It turns out that
"He is a would-be actor" may mean two things
1) He poses as a actor but he is not.
2) He wants to be an actor.
You need to do it by context. As you say, it's often derogatory, but not always. Even native speakers would not be able to determine whether a value judgment was being made without other information. The sentence about the marines has enough context to tell that it's not negative, and you have inferred correctly. That's how to do it. Otherwise, you'd have to ask the person who said it what they meant.
I don't think 'would-be' has a default derogatory meaning myself.
A would-be actor is someone aspiring to become an actor, not necessarily someone of mediocre or inferior ability who is unlikely ever to achieve his goal. If you talk about a successful actor's early life before he began his career it would be acceptable to call him a would-be actor at that stage.
As for someone who poses as an actor when he isn't one, you could use, self-styled, so-called, or 'wannabe', which exemplifies the derogatory aspect of 'would-be' and is derived from 'want to be'.