Is it consistent to add to $\sf MK$, a primitive total unary function symbol $\frak c$ standing for the cardinality of a class, axiomatize:
Hume's Principle : $\forall X \forall Y: {\frak c}(X) = {\frak c}(Y) \iff ( X \rightarrowtail Y \land Y \rightarrowtail X)$
Set-hood: $\forall X: {\frak c}(X) \in V$
Where $V$ is the class of all sets.
The symbol ${\frak c}$ is allowed to be used in comprehension and replacement.
$\mathsf{MK}$ proves that such a function exist, but it's not very interesting. One of the axioms of $\mathsf{MK}$ is the Axiom of Limitation of Size, which asserts that a class $X$ is a proper class iff it has a bijection with the universe $V$. Consequently, if $X$ and $Y$ are proper classes, then $\mathfrak{c}(X) = \mathfrak{c}(Y)$ always holds. In other words, there is essentially only one "cardinality" for proper classes.
More formally, you can define $\mathfrak{c}$ as follows: $$ \mathfrak{c}(X) := \begin{cases} |X|, &\text{if $X$ is a set} \\ \{1\}, &\text{otherwise} \end{cases} $$ Here $\{1\}$ is arbitrarily chosen, and you can replace it with any definable set which is not a cardinal. Note that the sentence "$X$ is a set" is equivalent to $\exists W[X \in W]$. Therefore, $\mathfrak{c}$ is class-definable, so it can be used in class comprehension and replacement.