For the sake of the MSE search engine, I'm summarizing the discussion in the associated MO post.
First, note that each group can be considered to be a (relatively simple) category. If we assume that our semidirect factors $N$ and $K$ are encoded this way, then one can encode $\theta$ as a functor $K\to\textbf{Cat}$ sending $\star\mapsto N$. Post-encoding, one obtains a nice description of $N\rtimes K$ as a Grothendieck construction/Kan extension $\int^K{N}$. If you want fancy names, then this describes $N\rtimes K$ as a lax 2-colimit.
Unfortunately, you probably don't just want fancy names: you probably want a description of semidirect products that is element-free. The encoding process to make a lax 2-colimit construction elevates each element of $N$ and $K$ to a category morphism, which defeats the point. So can we give an element-free description?
Yes! Consider the morphism category $\textbf{Mor}(\textbf{Grp})$ which consists of group homomorphisms $A\to B$. An element $F\in\textbf{Mor}(\textbf{Grp})$ defines a map $A\to\text{Aut}(B)$; elements of $A$ act on $B$ by conjugating by the image under $F$. There is a forgetful functor dropping the specific map $A\to B$ in favor of the action $A\to\text{Aut}(B)$; the mapping taking $K\to\text{Aut}(N)$ to the inclusion $K\to N\rtimes K$ is the left-adjoint of that forgetful functor.
Both of these options are discussed on the $n$-CatLab.
Lastly, one might object that both of these constructions build the semidirect product as a colimits. One usually encounters semidirect products are a generalization of direct products, which are limits, so one might hope for a limit construction. But this is something of a coincidence: the direct product is a quotient of the coproduct (free product) via $$N\times H=N*H/\langle\!\langle nhn^{-1}h^{-1}\rangle\!\rangle_{n\in N, h\in H}$$ where $\langle\!\langle\cdot\rangle\!\rangle$ denotes the normal closure generated by those elements. A semidirect product is a twist of this quotient via $$N\times H=N*H/\langle\!\langle nhn^{-1}\theta_h(n)^{-1}\rangle\!\rangle_{n\in N, h\in H}$$ Indeed, within the category of groups (or, really, any subcategory of pointed sets), a direct product has both projection and injection maps to and from (respectively) each direct factor. The projections are what makes it a direct product…and the condition that semidirect products choose to weaken.