Your code is pretty close to correct, just a small mistake in the base case:
In an empty list, you return an empty list. Therefore, if you have a list (6) , you add 6 to foo from an empty list, which is an empty list. This does not work because you cannot add a number to the list.
You can easily fix this by making foo return 0 instead of lst when lst empty.
As a side note: Mixing cond and if like this seems a bit redundant. I would write it like this using cond instead:
(defun foo (lst) (cond ((null lst) 0) ((> (car lst) 3) (1+ (foo (cdr lst)))) (T (foo (cdr lst)))))
source share