There's actually a template for that in the official rules - see here.
That link contains all the information on creating a lycanthrope template for any were-thingy you can think of :)
The specific details for a were-rex follow.
rule quotes are shown like this
specific details will appear below them like this.
Creating a Lycanthrope
“Lycanthrope” is an inherited (for natural lycanthropes) or acquired (for afflicted lycanthropes) template that can be added to any humanoid.
Challenge Rating: Same as base creature or base animal (whichever is higher) +1.
T-rex's CR is 9, so were-rex has CR: 10
(not that important for a PC, but this shows how powerful/unbalanced such a PC will be...)
Size and Type: The creature (referred to hereafter as the base creature) gains the shapechanger subtype. The lycanthrope takes on the characteristics of some type of animal (referred to hereafter as the base animal) within one size category of the base creature's size. A lycanthrope's hybrid form is the same size as the base animal or the base creature, whichever is larger.
(emphasis mine) T-rex size is Gargantuan, so a proper base creature has to be at least Huge for this template (this is another hint that this can create balance issues). If you house(over-)rule this, you get: Size: Medium (humanoid form), Gargantuan (hybrid and dinosaur form) and Type: humanoid (dwarf, shapechanger).
AC: In hybrid or animal form the lycanthrope has the natural armor bonus of the base animal increased by +2.
So, AC: hybrid and dino form: +16 natural, –4 size. (Calculate the modifiers from Dex, feats, etc., and add them up as normal.)
Defensive Abilities: A natural lycanthrope gains DR 10/silver in animal or hybrid form. An afflicted lycanthrope gains DR 5/silver in animal or hybrid form.
Your dwarf gets afflicted, so he has Defensive Abilities: DR 5/silver in dino or hybrid form.
Speed: Same as the base creature or base animal, depending on which form the lycanthrope is using. Hybrids use the base creature's speed.
(Exactly what it says on the can.) Speed: 40 ft. (in dino form)
Melee: A lycanthrope gains natural attacks in animal and hybrid forms according to the base animal.
The bite damage normally adds 1.5 x Str modifer, but since T-rex has the powerful bite special quality, it is 2 x Str modifer instead.
Melee: bite BAB + Str + Size (4d6+(Str x 2)/19–20 plus grab) only in dino and hybrid forms
Special Attacks: A lycanthrope retains all the special attacks, qualities, and abilities of the base creature. In hybrid or animal form it gains the special attacks, qualities, and abilities of the base animal. A lycanthrope also gains low-light vision, scent, and the following: Change Shape (Su), Curse of Lycanthropy (Su), Lycanthropic Empathy (Ex)
Special Attacks: swallow whole (2d8+11, AC 17, hp 15)
SQ: powerful bite(Ex), Change Shape (Su), Curse of Lycanthropy (Su), Lycanthropic Empathy (Ex)
Senses: low-light vision, scent
Skills: Racial Modifiers: +8 Perception
Ability Scores: +2 Wis, –2 Cha in all forms; +2 Str, +2 Con in hybrid and animal forms. Lycanthropes have enhanced senses but are not fully in control of their emotions and animalistic urges. In addition to these adjustments to the base creature's stats, a lycanthrope's ability scores change when he assumes hybrid or animal form. In human form, the lycanthrope's ability scores are unchanged from the base creature's form. In animal and hybrid form, the lycanthrope's ability scores are the same as the base creature's or the base animal's, whichever ability score is higher.
So, the dwarf will get +2 Wis, –2 Cha. Also, in dino and hybrid forms, for each ability, take the higher one between the dwarf's and what's below:
Str 34, Dex 13, Con 21, Int 2, Wis 17, Cha 8
As you see, this will be an incredibly powerful upgrade for your dwarf. it may be a better idea to base the template on a Large T-rex companion instead of on the fully grown beast (see the first sidebar to the right here) - If you find it too difficult to calculate that yourself, ask in a comment and I'll add that here as well (don't have the time to get to that right now, though). Using the companion statistics will still make him a badass without giving him an unbalancing push to something which is more like a super-powered NPC than a playable PC...