Typesetting the mathematical expression "const." How do I write in the right way, that something is constant?

I think, usually one does write = const., which should be an abbreviation for the Latin constat.

Should I write the expression italic ($\textit{const.}$) or upright ($\textrm{const.}$)? As far as I know, fixed mathematical operators should be written upright, but this isn't an operator...
Formally speaking, the right way to doing it would be to write something like
$$\int 2x\, \mathrm{d}x = x^2 + k, \ \text{where } k \text{ is constant}$$
If you did insist on doing it that way, to me it would look weird if it was italicised: italicised letters inside equations or formulae are usually interpreted as variables, so you technically end up with some ambiguity if any of the letters $c,o,n,s,t$ are used as variables. So I'd certainly prefer
$$\int 2x\, \mathrm{d}x = x^2 + \text{const.}$$
...but, of course, there is no Mathematical Institute of the Universe to govern this kind of thing, so as they say on Jersey Shore, you do you.
I believe your question has a definite answer if you fix a particular formal language, e.g. the language of first-order logic, in which you express a well-formed formula.

You could specify a constant symbol from the signature of the language to address a particular term in the domain of discourse. You could use quantifiers (if those exist in your language) to express a more complex association of an expression with a fixed member of the domain.