Great question. Yes, this is certainly possible and it can be done a couple of different ways. You can edit the code and add it in that way or there is an app which can help you with this too. Let's go through these options below:
<p>Discount Code: XXXX</p>
Where the X's are you can input your discount code then.
The other way about this is via an app. The app is called Kartify and can be found in the Shopify app store here. Kartify can help you edit the cart without the need to code anything but does have a monthly cost. Some of the main features of Kartify include incentivizing a checkout with a coupon code, adding a banner to your cart page, showing custom messages or notifications.
Hope this helps and don't hesitate to reach out should you have any questions.
All the best, Nick