(Note: there are parts of this solution that are sub-optimal, and I'm aware of that, but I'll have to fix that later. I'll remove this note when I find the time to improve things.)
You can change the files theorems-ams.module and theorems-ams.inc, or better create copies as described in my answer to How to make "claim" environments look like "theorem" environment?
In theorems-ams.module, add xcolor to the required packages. I.e. where it says
Requires amsmath,amsthm
edit this to
Requires amsmath,amsthm,xcolor
(This bit is untested, but I assume it will work.)
In theorems-ams.inc, find the style you want to change, for example the block defining the look of theorems starts with Style Theorem.
In the Style block there is a sub block Preamble, which by default looks like
Preamble
\theoremstyle{plain}
\newtheorem{thm}{\protect\theoremname}
EndPreamble
Using code taken from egreg's answer to amsthm environment and colorbox, edit this to read
Preamble
\newtheoremstyle{Coloredtheo}%
{3pt} %Space above
{3pt} %Space below
{} %Body font
{} %Indent amount
{\bfseries} %Theorem head font
{} %Punctuation after theorem head
{0.25em} %Space after theorem head
{\colorbox{red}{\color{black}\thmname{#1}%
\thmnumber{\@ifnotempty{#1}{ }\@upn{#2}}}%
\thmnote{ {--- \the\thm@notefont#3.}}%
} %Theorem head spec
\theoremstyle{Coloredtheo}
\newtheorem{thm}{\protect\theoremname}
EndPreamble
Note that this will not change the view in LyX, only in the PDF. Do similarly for Definition, but use a different name for the \newtheoremstyle. The background colour is set by the first argument to \colorbox, here red.
For a single document, you could use the Local layout under Documents --> Settings. Add the entire Style block to the local layout. You may need to also include \usepackage{xcolor} to the Preamble block.
In any case, I tried your solution but it only changed the font color in LyX (and not in the PDF output). Am I missing something?
– doodle Mar 26 '14 at 20:55{}to{.}in the%Punctuation, but this adds the dot outside of the color box. – doodle Mar 26 '14 at 23:27\@upn{#2}}to\@upn{#2}}{.}in your code. That took care of that dot. // Also, I kept theColor Redparameter underLabel Font, which you mentioned before your edit. It's not what I was looking for as far as end result in the PDF, but it does make LyX look slightly more like the PDF. Thanks again! – doodle Mar 26 '14 at 23:47