Avec l'extension `adjustbox` :
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{adjustbox}
\newenvironment{colbox}[1][yellow!50!white]{%
\begin{adjustbox}{bgcolor=#1}
}{%
\end{adjustbox}%
}
\begin{document}
\begin{table}
\centering\small
\begin{colbox}
\begin{tabular}{l}\hline
ligne 1 \\
ligne 2\\\hline
\end{tabular}
\end{colbox}
\end{table}
\begin{table}
\centering\small
\begin{colbox}[red]
\begin{tabular}{l}\hline
ligne 1 \\
ligne 2\\\hline
\end{tabular}
\end{colbox}
\end{table}
\end{document}
![alt text][1]
Ou avec `table` :
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{adjustbox}
\let\originaltable\table
\let\endoriginaltable\endtable
\renewenvironment{table}[1][htbp]{%
\originaltable[#1]
\centering\small%
\begin{adjustbox}{bgcolor=yellow!50!white}%
}%
{\end{adjustbox}\endoriginaltable}
\begin{document}
\begin{table}
\begin{tabular}{l}\hline
ligne 1 \\
ligne 2\\\hline
\end{tabular}
\end{table}
\begin{table}[b]
\begin{tabular}{l}\hline
ligne 1 \\
ligne 2\\\hline
\end{tabular}
\end{table}
\end{document}
[1]: https://texnique.fr/osqa/upfiles/Screen_Shot_2020-04-20_at_17.03.29.png