Yes, but in such a scenario, it is not necessarily the act itself that constitutes the sin. For example, killing a common house fly is NOT a mortal sin. If a person kills the fly thinking it is a mortal sin, the act of killing the fly remains morally neutral, while the person’s intention to commit a mortal sin remains.
In other words, a mortal sin can never come from an action which lacks the objective gravity necessary. Thus, the act of killing a common house fly (at least in any reasonably foreseeable circumstances) is simply not a mortal sin, where as the act of killing an innocent human being is objectively of mortal gravity. It is in the person’s interior disposition towards the act - and not the act itself (in situations where the act is not objectively a mortal sin) - that the mortal sin is committed. The grave matter for the sin is the desire to separate from God’s grace.