How to display the TID of a term reference field in a content type?
One "hacky" way to do this:

{# First step: capture the rendered output of the internal path link for a term #}  
{% set tid %}{{ content.field_category.0['#url'] }}{% endset %}

{# Second step: do some string processing on the captured output, removing the /taxonomy/term/ prefix and getting the TID #}  
{{ tid|trim|replace({ '/taxonomy/term/' : '' }) }}


Good luck!