# Is there a knapsack problem which allows 'out-of-capacity'?

I wonder if there is an option in the knapsack problem which has a huge cost for 'out-of-capacity' instead of strictly limiting the constraint.

You can introduce a nonnegative surplus variable $$y$$ with large cost $$M$$ and maximize $$\sum_j v_j x_j-M y$$ subject to $$\sum_j w_j x_j \le W+y$$.
Alternatively, if you want to impose a one-time fixed cost $$M$$ if there is any violation, let $$y$$ be binary and change the constraint to $$\sum_j w_j x_j \le W+Uy$$, where $$U$$ is some upper bound.