First you need to convert the image to PNG format, e.g. with ImageMagick's convert (Debian package imagemagick):

convert logo.jpg -resize 32x32 favicon.png

In the second step you convert it to a Favicon with icotool (Debian package icoutils):

icotool -c -o favicon.ico favicon.png