You could use something this:
(defun add-tangle-headers ()
(message "running in %s" (buffer-file-name))
(cond
((f-ext? (buffer-file-name) "py")
(goto-char (point-min))
(insert "# This is a generated file do not edit\n"))
((f-ext? (buffer-file-name) "el")
(goto-char (point-min))
(insert ";;; -*- lexical-binding: t -*-\n"))
(t
nil))
(save-buffer))
(add-hook 'org-babel-post-tangle-hook 'add-tangle-headers)
The idea is to insert the desired line depending on the kind of src file you are tangling.
I would have thought you could use a :prologue header arg, but this seems to be only for execution.
Alternatively, you might try noweb:
First, name some source blocks like this with the header you want in each one.
#+name: elisp-header
#+BEGIN_SRC emacs-lisp
;;; -*- lexical-binding: t -*-
#+END_SRC
#+name: python-header
#+BEGIN_SRC python
# This is a generated file do not edit
#+END_SRC
Then, add a noweb yes header arg, and the target in the blocks where you want them.
#+BEGIN_SRC emacs-lisp :tangle test.el :noweb yes
<<elisp-header>>
(message "ok")
#+END_SRC
#+BEGIN_SRC python :tangle test.py :noweb yes
<<python-header>>
print('ok')
#+END_SRC
These will tangle as you want.