How to add a simple calculated field to a google form?

As others mentioned, Google Forms does not support calculating values in realtime. However, there are 2 Google Forms addons that let you do that (Disclaimer: I created them):

  1. For simple expressions like the ones you mentioned (quantity * price = total_price) you can use Formfacade addon - https://formfacade.com/website/google-forms-calculated-fields.html
  2. For sophisticated order forms with order total, delivery fee and order summary, you can use Neartail addon - https://formfacade.com/neartail/automatically-calculate-total-amount-in-order-form.html

Scripting only can affect the creation and post-submit processing of a form. You cannot make any changes to the "live" form the user is currently looking at. What you can do is send an email to the user after the form has been submitted with a calculated summery. You could include a link to the getEditResponseUrl() if they see any errors.