The tufte documentclass loads the titlesec package, so we have immediate access to all of its excellent features.
Indeed, tufte-common.def contains declarations for each of chapter, section and subsection using the titleformat. We can tweak them to give us what we want- in your case, using colorbox to help us. A complete MWE is at the end, but here's the bit that we need for your requirements:
% chapter format
\titleformat{\chapter}%
{\huge\rmfamily\itshape\color{red}}% format applied to label+text
{\llap{\colorbox{red}{\parbox{1.5cm}{\hfill\itshape\huge\color{white}\thechapter}}}}% label
{2pt}% horizontal separation between label and title body
{}% before the title body
[]% after the title body
Note that I've used \llap to push the number into the left margin- you can tweak the horizontal separator as you wish. The tweaks for section and subsection are very similar.
The only other subtlety is that I have used
\setcounter{secnumdepth}{2}
so that we get numbers for all of the section headings (the default value is -1 which turns all the numbers off).

\documentclass[a4paper,twoside]{tufte-book}
\usepackage{xcolor} % for colour
\usepackage{lipsum} % just for sample text
% add numbers to chapters, sections, subsections
\setcounter{secnumdepth}{2}
% chapter format
\titleformat{\chapter}%
{\huge\rmfamily\itshape\color{red}}% format applied to label+text
{\llap{\colorbox{red}{\parbox{1.5cm}{\hfill\itshape\huge\color{white}\thechapter}}}}% label
{2pt}% horizontal separation between label and title body
{}% before the title body
[]% after the title body
% section format
\titleformat{\section}%
{\normalfont\Large\itshape\color{orange}}% format applied to label+text
{\llap{\colorbox{orange}{\parbox{1.5cm}{\hfill\color{white}\thesection}}}}% label
{1em}% horizontal separation between label and title body
{}% before the title body
[]% after the title body
% subsection format
\titleformat{\subsection}%
{\normalfont\large\itshape\color{blue}}% format applied to label+text
{\llap{\colorbox{blue}{\parbox{1.5cm}{\hfill\color{white}\thesubsection}}}}% label
{1em}% horizontal separation between label and title body
{}% before the title body
[]% after the title body
\begin{document}
\chapter{Chapter}
\lipsum[1]
\section{Section}
\lipsum[1]
\subsection{Sub section}
\lipsum[1]
\end{document}